From 7937ab98664d31ab3e675ee48cbf7a2d56010fc0 Mon Sep 17 00:00:00 2001 From: Austin Beam Date: Sat, 3 May 2014 17:55:10 -0500 Subject: [PATCH 1/3] tmux: Shell variable definition for tmux version Add variables for tmux major and minor version numbers. These can subsequently be used to test for tmux version compatibility. --- powerline/bindings/tmux/powerline.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/powerline/bindings/tmux/powerline.conf b/powerline/bindings/tmux/powerline.conf index 48c87b51..ea33c866 100644 --- a/powerline/bindings/tmux/powerline.conf +++ b/powerline/bindings/tmux/powerline.conf @@ -1,4 +1,6 @@ if-shell 'test -z "$POWERLINE_COMMAND"' 'if-shell "which powerline-client" "set-environment -g POWERLINE_COMMAND powerline-client" "set-environment -g POWERLINE_COMMAND powerline"' +run-shell "tmux set-environment -g TMUX_VERSION_MAJOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f1 | sed 's/[^0-9]*//g')" +run-shell "tmux set-environment -g TMUX_VERSION_MINOR $(tmux -V | cut -d' ' -f2 | cut -d'.' -f2 | sed 's/[^0-9]*//g')" set -g status on set -g status-utf8 on set -g status-interval 2 From 478e49773b61d2634ffcca01ddf8b4ee3b7828a7 Mon Sep 17 00:00:00 2001 From: Austin Beam Date: Sat, 3 May 2014 17:57:13 -0500 Subject: [PATCH 2/3] tmux: Check version for prefix active colorization Prefix active colorization feature introduced by pull request #863 causes undesired behavior on older versions of tmux. Add version checking and revert to old powerline configuration if the tmux version is less than v1.8. tmux v1.8 was the first version to support the client_prefix format variable. --- powerline/bindings/tmux/powerline.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/powerline/bindings/tmux/powerline.conf b/powerline/bindings/tmux/powerline.conf index ea33c866..16204739 100644 --- a/powerline/bindings/tmux/powerline.conf +++ b/powerline/bindings/tmux/powerline.conf @@ -7,7 +7,10 @@ set -g status-interval 2 set -g status-fg colour231 set -g status-bg colour234 set -g status-left-length 20 -set -g status-left '#{?client_prefix,#[fg=colour254]#[bg=colour31]#[bold],#[fg=colour16]#[bg=colour254]#[bold]} #S #{?client_prefix,#[fg=colour31]#[bg=colour234]#[nobold],#[fg=colour254]#[bg=colour234]#[nobold]}#(eval $POWERLINE_COMMAND tmux left)' +# Version check for 'client_prefix' format functionality +if-shell '[ $TMUX_VERSION_MAJOR -gt 1 -o \( $TMUX_VERSION_MAJOR -eq 1 -a $TMUX_VERSION_MINOR -ge 8 \) ]' \ + "set -g status-left '#{?client_prefix,#[fg=colour254]#[bg=colour31]#[bold],#[fg=colour16]#[bg=colour254]#[bold]} #S #{?client_prefix,#[fg=colour31]#[bg=colour234]#[nobold],#[fg=colour254]#[bg=colour234]#[nobold]}#(eval $POWERLINE_COMMAND tmux left)'" \ + "set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]#(eval $POWERLINE_COMMAND tmux left)'" set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)' set -g status-right-length 150 set -g window-status-format "#[fg=colour244,bg=colour234]#I #[fg=colour240] #[default]#W " From 20d326fd4538610ad4edee82c144859695c8897d Mon Sep 17 00:00:00 2001 From: Austin Beam Date: Sat, 3 May 2014 17:58:43 -0500 Subject: [PATCH 3/3] tmux: Check version for last window indication Last active window indication feature introduced by pull request #864 causes undesired behavior on older versions of tmux. Add version checking to determine which method for feature implementation to use, dropping the feature entirely for tmux versions less that v1.8. For tmux v1.9, use the newer 'window-status-last-style' option rather than the deprecated (starting with v1.9) 'window-status-last-fg' option. Ideally, the other `foo-{attr,fg,bg}` options used in the `tmux` powerline config file should also be version checked and replaced with the corresponding `foo-style` option as well. --- powerline/bindings/tmux/powerline.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/powerline/bindings/tmux/powerline.conf b/powerline/bindings/tmux/powerline.conf index 16204739..6facec9c 100644 --- a/powerline/bindings/tmux/powerline.conf +++ b/powerline/bindings/tmux/powerline.conf @@ -15,7 +15,10 @@ set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux displ set -g status-right-length 150 set -g window-status-format "#[fg=colour244,bg=colour234]#I #[fg=colour240] #[default]#W " set -g window-status-current-format "#[fg=colour234,bg=colour31]#[fg=colour117,bg=colour31] #I  #[fg=colour231,bold]#W #[fg=colour31,bg=colour234,nobold]" -set -g window-status-last-fg colour31 +# Version check for window-status-last-style and/or window-status-last-fg functionality +if-shell '[ $TMUX_VERSION_MAJOR -gt 1 -o \( $TMUX_VERSION_MAJOR -eq 1 -a $TMUX_VERSION_MINOR -ge 9 \) ]' \ + "set -g window-status-last-style fg=colour31" \ + 'if-shell "[ $TMUX_VERSION_MAJOR -eq 1 -a $TMUX_VERSION_MINOR -ge 8 ]" "set -g window-status-last-fg colour31"' set-window-option -g window-status-fg colour249 set-window-option -g window-status-activity-attr none set-window-option -g window-status-bell-attr none