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.
This commit is contained in:
Fernando Schauenburg 2020-12-04 18:15:41 +01:00
parent 46936dffa9
commit 6b4f2ecf85
4 changed files with 24 additions and 20 deletions

View file

@ -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"

View file

@ -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

View file

@ -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/

View file

@ -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