From 90c98999ec34aad756cd896d8bf6b2cd2fbcb3f6 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Fri, 3 Apr 2026 22:46:44 +0200 Subject: [PATCH] Add layered Bash editor environment snippets --- ansible/inventory/group_vars/all.yml | 4 ++++ ansible/inventory/group_vars/desktop.yml | 4 ++++ ansible/inventory/group_vars/ubuntu.yml | 5 +++++ ansible/roles/packages_ubuntu/tasks/main.yml | 12 ++++++++++++ dotfiles/common/.bashrc | 9 +++++++++ dotfiles/common/.bashrc.aliases | 2 ++ dotfiles/desktop/.bashrc.d/20-editor-desktop.sh | 2 ++ dotfiles/ubuntu/.bashrc.d/20-editor-ubuntu.sh | 1 + 8 files changed, 39 insertions(+) create mode 100644 dotfiles/common/.bashrc.aliases create mode 100644 dotfiles/desktop/.bashrc.d/20-editor-desktop.sh create mode 100644 dotfiles/ubuntu/.bashrc.d/20-editor-ubuntu.sh diff --git a/ansible/inventory/group_vars/all.yml b/ansible/inventory/group_vars/all.yml index e2c5695..0ffcf81 100644 --- a/ansible/inventory/group_vars/all.yml +++ b/ansible/inventory/group_vars/all.yml @@ -41,6 +41,10 @@ common_dotfiles: src: .bash_profile dest: .bash_profile mode: "0644" + - name: .bashrc.aliases + src: .bashrc.aliases + dest: .bashrc.aliases + mode: "0644" - name: .vimrc src: .vimrc dest: .vimrc diff --git a/ansible/inventory/group_vars/desktop.yml b/ansible/inventory/group_vars/desktop.yml index 2c82eff..7225c3e 100644 --- a/ansible/inventory/group_vars/desktop.yml +++ b/ansible/inventory/group_vars/desktop.yml @@ -157,6 +157,10 @@ desktop_common_dotfiles: src: .config/opencode/ dest: .config/opencode/ mode: preserve + - name: Bash profile fragments + src: .bashrc.d/ + dest: .bashrc.d/ + mode: preserve - name: .gitignore_global src: .gitignore_global dest: .gitignore_global diff --git a/ansible/inventory/group_vars/ubuntu.yml b/ansible/inventory/group_vars/ubuntu.yml index 6c7943b..983437c 100644 --- a/ansible/inventory/group_vars/ubuntu.yml +++ b/ansible/inventory/group_vars/ubuntu.yml @@ -22,3 +22,8 @@ ubuntu_docker_packages: enabled_services: - ufw - docker + +ubuntu_dotfiles: + - src: .bashrc.d/ + dest: .bashrc.d/ + mode: preserve diff --git a/ansible/roles/packages_ubuntu/tasks/main.yml b/ansible/roles/packages_ubuntu/tasks/main.yml index 5d78fb4..d5ef039 100644 --- a/ansible/roles/packages_ubuntu/tasks/main.yml +++ b/ansible/roles/packages_ubuntu/tasks/main.yml @@ -4,6 +4,18 @@ ansible.builtin.package_facts: manager: auto +- name: Copy Ubuntu dotfiles + tags: [dotfiles, dotfiles:common] + ansible.builtin.copy: + src: "{{ playbook_dir }}/../dotfiles/ubuntu/{{ item.src }}" + dest: "{{ effective_user_home }}/{{ item.dest }}" + owner: "{{ effective_username }}" + group: "{{ effective_user_group }}" + mode: "{{ item.mode }}" + loop: "{{ ubuntu_dotfiles | default([]) }}" + loop_control: + label: "{{ item.dest }}" + - name: Ensure architecture is supported for Google Chrome tags: [packages] ansible.builtin.fail: diff --git a/dotfiles/common/.bashrc b/dotfiles/common/.bashrc index a1fb18c..7333c9a 100644 --- a/dotfiles/common/.bashrc +++ b/dotfiles/common/.bashrc @@ -39,6 +39,13 @@ shopt -s cmdhist [ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" export PATH +if [ -d "$HOME/.bashrc.d" ]; then + for bashrc_file in "$HOME"/.bashrc.d/*.sh; do + [ -r "$bashrc_file" ] || continue + . "$bashrc_file" + done +fi + # ========================= # Aliases (portable) # ========================= @@ -420,3 +427,5 @@ elif [ "$PLATFORM" = "linux" ]; then alias df='df -h' alias du='du -h' fi + +[ -r "$HOME/.bashrc.aliases" ] && . "$HOME/.bashrc.aliases" diff --git a/dotfiles/common/.bashrc.aliases b/dotfiles/common/.bashrc.aliases new file mode 100644 index 0000000..ddbb6c9 --- /dev/null +++ b/dotfiles/common/.bashrc.aliases @@ -0,0 +1,2 @@ +# Additional Bash aliases. +# Keep this file as the extension point for shared aliases. diff --git a/dotfiles/desktop/.bashrc.d/20-editor-desktop.sh b/dotfiles/desktop/.bashrc.d/20-editor-desktop.sh new file mode 100644 index 0000000..0e1b4e5 --- /dev/null +++ b/dotfiles/desktop/.bashrc.d/20-editor-desktop.sh @@ -0,0 +1,2 @@ +export EDITOR=vim +export VISUAL=emacs diff --git a/dotfiles/ubuntu/.bashrc.d/20-editor-ubuntu.sh b/dotfiles/ubuntu/.bashrc.d/20-editor-ubuntu.sh new file mode 100644 index 0000000..d46bf43 --- /dev/null +++ b/dotfiles/ubuntu/.bashrc.d/20-editor-ubuntu.sh @@ -0,0 +1 @@ +export EDITOR=vim