added tmux and all
This commit is contained in:
3
roles/all/meta/main.yml
Normal file
3
roles/all/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- role: local.fish_shell.tmux
|
||||
- role: local.fish_shell.fish
|
||||
39
roles/tmux/tasks/main.yml
Normal file
39
roles/tmux/tasks/main.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- name: Install tmux
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- "tmux"
|
||||
- "git"
|
||||
|
||||
- name: Get all users from /etc/passwd
|
||||
ansible.builtin.getent:
|
||||
database: passwd
|
||||
register: all_users
|
||||
|
||||
- name: Create a list of home directories for bash and zsh users
|
||||
set_fact:
|
||||
user_home_dirs: "{{ user_home_dirs | default([]) + [item.value[4]] }}"
|
||||
loop: "{{ all_users.ansible_facts.getent_passwd | dict2items }}"
|
||||
when: item.value[5] in ['/bin/bash', '/bin/zsh', '/usr/bin/bash', '/usr/bin/zsh', '/usr/bin/fish']
|
||||
|
||||
- name: Display the list of collected home directories
|
||||
ansible.builtin.debug:
|
||||
var: user_home_dirs
|
||||
|
||||
- name: Tmux config Play
|
||||
include_tasks: tmux_config.yml
|
||||
loop: "{{ user_home_dirs }}"
|
||||
|
||||
# ========================================================================
|
||||
# EXAMPLE: Here is how you can reuse the 'user_home_dirs' list
|
||||
# This example task iterates through the list of home directories
|
||||
# and creates a file named 'test.txt' in each directory.
|
||||
# ========================================================================
|
||||
# - name: Example - Create a file in each home directory
|
||||
# ansible.builtin.file:
|
||||
# path: "{{ item }}/test.txt"
|
||||
# state: touch
|
||||
# mode: '0644'
|
||||
# loop: "{{ user_home_dirs }}"
|
||||
63
roles/tmux/tasks/tmux_config.yml
Normal file
63
roles/tmux/tasks/tmux_config.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Define user and home directory variables
|
||||
ansible.builtin.set_fact:
|
||||
config_owner: "{{ item | basename }}"
|
||||
home_dir: "{{ item }}"
|
||||
|
||||
- name: Define plugins to install
|
||||
ansible.builtin.set_fact:
|
||||
tmux_plugins:
|
||||
- { name: 'catppuccin', repo: 'https://github.com/catppuccin/tmux.git', path: 'plugin/catppuccin', version: 'v2.1.0' }
|
||||
- { name: 'tmux-cpu', repo: 'https://github.com/tmux-plugins/tmux-cpu.git', path: 'plugins/tmux-plugins/tmux-cpu', version: 'master' }
|
||||
- { name: 'tmux-battery', repo: 'https://github.com/tmux-plugins/tmux-battery.git', path: 'plugins/tmux-plugins/tmux-battery', version: 'master' }
|
||||
|
||||
- name: "Create plugin directories"
|
||||
ansible.builtin.file:
|
||||
path: "{{ home_dir }}/.config/tmux/{{ plugin_item.path }}"
|
||||
state: directory
|
||||
owner: "{{ config_owner }}"
|
||||
group: "{{ config_owner }}"
|
||||
mode: '0755'
|
||||
loop: "{{ tmux_plugins }}"
|
||||
loop_control:
|
||||
loop_var: plugin_item
|
||||
|
||||
- name: "Add git safe.directories"
|
||||
ansible.builtin.command: "git config --global --add safe.directory {{ home_dir }}/.config/tmux/{{ plugin_item.path }}"
|
||||
changed_when: false
|
||||
loop: "{{ tmux_plugins }}"
|
||||
loop_control:
|
||||
loop_var: plugin_item
|
||||
|
||||
- name: "Clone plugins"
|
||||
ansible.builtin.git:
|
||||
repo: "{{ plugin_item.repo }}"
|
||||
dest: "{{ home_dir }}/.config/tmux/{{ plugin_item.path }}"
|
||||
version: "{{ plugin_item.version }}"
|
||||
loop: "{{ tmux_plugins }}"
|
||||
loop_control:
|
||||
loop_var: plugin_item
|
||||
|
||||
- name: "Set plugin ownership"
|
||||
ansible.builtin.file:
|
||||
path: "{{ home_dir }}/.config/tmux/{{ plugin_item.path }}"
|
||||
state: directory
|
||||
owner: "{{ config_owner }}"
|
||||
group: "{{ config_owner }}"
|
||||
recurse: yes
|
||||
loop: "{{ tmux_plugins }}"
|
||||
loop_control:
|
||||
loop_var: plugin_item
|
||||
|
||||
- name: Set catppuccin_install_path for template
|
||||
ansible.builtin.set_fact:
|
||||
catppuccin_install_path: "{{ home_dir }}/.config/tmux/{{ (tmux_plugins | selectattr('name', 'equalto', 'catppuccin') | first).path }}"
|
||||
|
||||
- name: Install Template
|
||||
ansible.builtin.template:
|
||||
src: "tmux.conf.j2"
|
||||
dest: "{{ home_dir }}/.tmux.conf"
|
||||
owner: "{{ config_owner }}"
|
||||
group: "{{ config_owner }}"
|
||||
mode: '0644'
|
||||
|
||||
27
roles/tmux/templates/tmux.conf.j2
Normal file
27
roles/tmux/templates/tmux.conf.j2
Normal file
@@ -0,0 +1,27 @@
|
||||
# ~/.tmux.conf
|
||||
|
||||
# Options to make tmux more pleasant
|
||||
set -g mouse on
|
||||
set -g default-terminal "tmux-256color"
|
||||
|
||||
# Configure the catppuccin plugin
|
||||
set -g @catppuccin_flavor "mocha" # latte, frappe, macchiato, or mocha
|
||||
set -g @catppuccin_window_status_style "rounded" # basic, rounded, slanted, custom, or none
|
||||
|
||||
# Load catppuccin
|
||||
run {{ catppuccin_install_path }}/catppuccin.tmux
|
||||
# For TPM, instead use `run ~/.config/tmux/plugins/tmux/catppuccin.tmux`
|
||||
|
||||
# Make the status line pretty and add some modules
|
||||
set -g status-right-length 100
|
||||
set -g status-left-length 100
|
||||
set -g status-left ""
|
||||
set -g status-right "#{E:@catppuccin_status_application}"
|
||||
set -agF status-right "#{E:@catppuccin_status_cpu}"
|
||||
set -ag status-right "#{E:@catppuccin_status_session}"
|
||||
set -ag status-right "#{E:@catppuccin_status_uptime}"
|
||||
set -agF status-right "#{E:@catppuccin_status_battery}"
|
||||
|
||||
run ~/.config/tmux/plugins/tmux-plugins/tmux-cpu/cpu.tmux
|
||||
run ~/.config/tmux/plugins/tmux-plugins/tmux-battery/battery.tmux
|
||||
# Or, if using TPM, just run TPM
|
||||
Reference in New Issue
Block a user