From 6b4f2ecf858f5dc9eae1f4d5ffac676fb4f62bd0 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 4 Dec 2020 18:15:41 +0100 Subject: [PATCH] fix(tmux): changing background was ignored by tmux When moving the configuration files to $XDG_CONFIG_HOME I forgot to change the line in .bashrc that sources the tmux configuration so bash was still trying to source ~/.tmux.conf, which no longer exists. This commit fixes that. Additionally, the color setting code has been factored out of tmux.conf into tmux-colors.conf (which can be sourced from bash profile and tmux.conf). This way the rest of the code in tmux.conf doesn't have to be executed again when changing the background color. --- roles/bash/files/profile | 4 ++-- roles/tmux/files/tmux-colors.conf | 16 ++++++++++++++++ roles/tmux/files/tmux.conf | 16 +--------------- roles/tmux/tasks/main.yml | 8 +++++--- 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 roles/tmux/files/tmux-colors.conf diff --git a/roles/bash/files/profile b/roles/bash/files/profile index 6dc28a6..5e5eb3a 100644 --- a/roles/bash/files/profile +++ b/roles/bash/files/profile @@ -252,9 +252,9 @@ _update_colors() { PS1_SEP_COLOR=$(tput setaf $Base01) fi - if [ -n "$TMUX" ] && [ -f "$HOME/.tmux.conf" ]; then + if [ -n "$TMUX" ] && [ -f "$XDG_CONFIG_HOME/tmux/tmux-colors.conf" ]; then tmux set-environment -g BACKGROUND "$BACKGROUND" - tmux source-file "$HOME/.tmux.conf" + tmux source-file "$XDG_CONFIG_HOME/tmux/tmux-colors.conf" fi local ls_colors="$HOME/.config/dircolors/solarized-$BACKGROUND" diff --git a/roles/tmux/files/tmux-colors.conf b/roles/tmux/files/tmux-colors.conf new file mode 100644 index 0000000..c72d9b4 --- /dev/null +++ b/roles/tmux/files/tmux-colors.conf @@ -0,0 +1,16 @@ +# Default to solarized dark. +set -g status-fg colour3 # Yellow +set -g status-bg colour0 # Base02 +setw -g window-status-style fg=colour12,bg=default # Base0 on Transparent +setw -g window-status-current-style fg=colour9,bg=default # Orange on Transparent +set -g pane-border-style fg=colour0 # Base02 +set -g pane-active-border-style fg=colour14 # Base1 + +%if #{==:#{BACKGROUND},light} + set -g status-fg colour13 # Violet + set -g status-bg colour7 # Base2 + setw -g window-status-style fg=colour11,bg=default # Base00 on Transparent + setw -g window-status-current-style fg=colour5,bg=default # Magenta on Transparent + set -g pane-border-style fg=colour7 # Base2 + set -g pane-active-border-style fg=colour10 # Base01 +%endif diff --git a/roles/tmux/files/tmux.conf b/roles/tmux/files/tmux.conf index f279a69..54f0904 100644 --- a/roles/tmux/files/tmux.conf +++ b/roles/tmux/files/tmux.conf @@ -55,21 +55,7 @@ set-environment -gu SHLVL # # Colors # -set -g status-fg colour3 # Yellow -set -g status-bg colour0 # Base02 -setw -g window-status-style fg=colour12,bg=default # Base0 on Transparent -setw -g window-status-current-style fg=colour9,bg=default # Orange on Transparent -set -g pane-border-style fg=colour0 # Base02 -set -g pane-active-border-style fg=colour14 # Base1 - -%if #{==:#{BACKGROUND},light} - set -g status-fg colour13 # Violet - set -g status-bg colour7 # Base2 - setw -g window-status-style fg=colour11,bg=default # Base00 on Transparent - setw -g window-status-current-style fg=colour5,bg=default # Magenta on Transparent - set -g pane-border-style fg=colour7 # Base2 - set -g pane-active-border-style fg=colour10 # Base01 -%endif +source-file -q "$XDG_CONFIG_HOME/tmux/tmux-colors.conf" # Fix for clipboard in vim running inside tmux: # See http://www.economyofeffort.com/2013/07/29/reattach-to-user-namespace-the-fix-for-your-tmux-in-os-x-woes/ diff --git a/roles/tmux/tasks/main.yml b/roles/tmux/tasks/main.yml index 2e04c96..f8367ce 100644 --- a/roles/tmux/tasks/main.yml +++ b/roles/tmux/tasks/main.yml @@ -14,8 +14,10 @@ - name: Deploy tmux config file: - src: "{{ role_path }}/files/tmux.conf" - dest: ~/.config/tmux/tmux.conf + src: "{{ role_path }}/files/{{ item }}" + dest: "~/.config/tmux/{{ item }}" state: link force: yes - + loop: + - tmux.conf + - tmux-colors.conf