From 49e55bac061a72b3da0153e90fa03b7c48be6247 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 10 Dec 2019 16:57:28 +0100 Subject: [PATCH 01/28] aligned default tmux_conf_xxx variables with their .tmux.conf.local sample counterpart --- .tmux.conf | 143 +++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index eb78830..dde6fdc 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -771,8 +771,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_window_fg=${tmux_conf_theme_window_fg:-default} # tmux_conf_theme_window_bg=${tmux_conf_theme_window_bg:-default} # tmux_conf_theme_highlight_focused_pane=${tmux_conf_theme_highlight_focused_pane:-false} -# tmux_conf_theme_focused_pane_fg=${tmux_conf_theme_focused_pane_fg:-'default'} # default -# tmux_conf_theme_focused_pane_bg=${tmux_conf_theme_focused_pane_bg:-'#0087d7'} # light blue +# tmux_conf_theme_focused_pane_fg=${tmux_conf_theme_focused_pane_fg:-default} # default +# tmux_conf_theme_focused_pane_bg=${tmux_conf_theme_focused_pane_bg:-#0087d7} # light blue # # # tmux 1.9 doesn't really like set -q # if tmux show -g -w | grep -q window-style; then @@ -786,8 +786,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # # tmux_conf_theme_pane_border_style=${tmux_conf_theme_pane_border_style:-thin} -# tmux_conf_theme_pane_border=${tmux_conf_theme_pane_border:-'#444444'} # light gray -# tmux_conf_theme_pane_active_border=${tmux_conf_theme_pane_active_border:-'#00afff'} # light blue +# tmux_conf_theme_pane_border=${tmux_conf_theme_pane_border:-#444444} # light gray +# tmux_conf_theme_pane_active_border=${tmux_conf_theme_pane_active_border:-#00afff} # light blue # tmux_conf_theme_pane_border_fg=${tmux_conf_theme_pane_border_fg:-$tmux_conf_theme_pane_border} # tmux_conf_theme_pane_active_border_fg=${tmux_conf_theme_pane_active_border_fg:-$tmux_conf_theme_pane_active_border} # case "$tmux_conf_theme_pane_border_style" in @@ -796,14 +796,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-$tmux_conf_theme_pane_active_border_fg} # ;; # thin|*) -# tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-'default'} -# tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-'default'} +# tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-default} +# tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-default} # ;; # esac # tmux setw -g pane-border-style "fg=$tmux_conf_theme_pane_border_fg,bg=$tmux_conf_theme_pane_border_bg" \; set -g pane-active-border-style "fg=$tmux_conf_theme_pane_active_border_fg,bg=$tmux_conf_theme_pane_active_border_bg" # -# tmux_conf_theme_pane_indicator=${tmux_conf_theme_pane_indicator:-'#00afff'} # light blue -# tmux_conf_theme_pane_active_indicator=${tmux_conf_theme_pane_active_indicator:-'#00afff'} # light blue +# tmux_conf_theme_pane_indicator=${tmux_conf_theme_pane_indicator:-#00afff} # light blue +# tmux_conf_theme_pane_active_indicator=${tmux_conf_theme_pane_active_indicator:-#00afff} # light blue # # tmux set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator" # @@ -814,29 +814,29 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_right_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_main-}") # tmux_conf_theme_right_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_sub-|}") # -# tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-'#000000'} # black -# tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-'#ffff00'} # yellow -# tmux_conf_theme_message_attr=${tmux_conf_theme_message_attr:-'bold'} +# tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-#000000} # black +# tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-#ffff00} # yellow +# tmux_conf_theme_message_attr=${tmux_conf_theme_message_attr:-bold} # tmux set -g message-style "fg=$tmux_conf_theme_message_fg,bg=$tmux_conf_theme_message_bg,$tmux_conf_theme_message_attr" # -# tmux_conf_theme_message_command_fg=${tmux_conf_theme_message_command_fg:-'#ffff00'} # yellow -# tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-'#000000'} # black -# tmux_conf_theme_message_command_attr=${tmux_conf_theme_message_command_attr:-'bold'} +# tmux_conf_theme_message_command_fg=${tmux_conf_theme_message_command_fg:-#ffff00} # yellow +# tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-#000000} # black +# tmux_conf_theme_message_command_attr=${tmux_conf_theme_message_command_attr:-bold} # tmux set -g message-command-style "fg=$tmux_conf_theme_message_command_fg,bg=$tmux_conf_theme_message_command_bg,$tmux_conf_theme_message_command_attr" # -# tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-'#000000'} # black -# tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-'#ffff00'} # yellow -# tmux_conf_theme_mode_attr=${tmux_conf_theme_mode_attr:-'bold'} +# tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-#000000} # black +# tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-#ffff00} # yellow +# tmux_conf_theme_mode_attr=${tmux_conf_theme_mode_attr:-bold} # tmux setw -g mode-style "fg=$tmux_conf_theme_mode_fg,bg=$tmux_conf_theme_mode_bg,$tmux_conf_theme_mode_attr" # -# tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-'#8a8a8a'} # white -# tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-'#080808'} # dark gray -# tmux_conf_theme_status_attr=${tmux_conf_theme_status_attr:-'none'} +# tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-#8a8a8a} # white +# tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-#080808} # dark gray +# tmux_conf_theme_status_attr=${tmux_conf_theme_status_attr:-none} # tmux set -g status-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ # set -g status-left-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ # set -g status-right-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" # -# tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-'#h ❐ #S ● #I #W'} +# tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-#h ❐ #S ● #I #W} # # tmux_conf_theme_terminal_title=$(echo "$tmux_conf_theme_terminal_title" | sed \ # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ @@ -847,15 +847,15 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') # tmux set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")" # -# tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-'#8a8a8a'} # white -# tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-'#080808'} # dark gray -# tmux_conf_theme_window_status_attr=${tmux_conf_theme_window_status_attr:-'none'} -# tmux_conf_theme_window_status_format=${tmux_conf_theme_window_status_format:-'#I #W'} +# tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-#8a8a8a} # white +# tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-#080808} # dark gray +# tmux_conf_theme_window_status_attr=${tmux_conf_theme_window_status_attr:-none} +# tmux_conf_theme_window_status_format=${tmux_conf_theme_window_status_format:-#I #W} # -# tmux_conf_theme_window_status_current_fg=${tmux_conf_theme_window_status_current_fg:-'#000000'} # black -# tmux_conf_theme_window_status_current_bg=${tmux_conf_theme_window_status_current_bg:-'#00afff'} # light blue -# tmux_conf_theme_window_status_current_attr=${tmux_conf_theme_window_status_current_attr:-'bold'} -# tmux_conf_theme_window_status_current_format=${tmux_conf_theme_window_status_current_format:-'#I #W'} +# tmux_conf_theme_window_status_current_fg=${tmux_conf_theme_window_status_current_fg:-#000000} # black +# tmux_conf_theme_window_status_current_bg=${tmux_conf_theme_window_status_current_bg:-#00afff} # light blue +# tmux_conf_theme_window_status_current_attr=${tmux_conf_theme_window_status_current_attr:-bold} +# tmux_conf_theme_window_status_current_format=${tmux_conf_theme_window_status_current_format:-#I #W} # if [ x"$(tmux show -g -v status-justify)" = x"right" ]; then # tmux_conf_theme_window_status_current_format="#[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_window_status_bg]$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr] $tmux_conf_theme_window_status_current_format #[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_window_status_current_bg,none]$tmux_conf_theme_right_separator_main" # else @@ -882,49 +882,49 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # setw -g window-status-current-style "fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr" \;\ # setw -g window-status-current-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_current_format")" # -# tmux_conf_theme_window_status_activity_fg=${tmux_conf_theme_window_status_activity_fg:-'default'} -# tmux_conf_theme_window_status_activity_bg=${tmux_conf_theme_window_status_activity_bg:-'default'} -# tmux_conf_theme_window_status_activity_attr=${tmux_conf_theme_window_status_activity_attr:-'underscore'} +# tmux_conf_theme_window_status_activity_fg=${tmux_conf_theme_window_status_activity_fg:-default} +# tmux_conf_theme_window_status_activity_bg=${tmux_conf_theme_window_status_activity_bg:-default} +# tmux_conf_theme_window_status_activity_attr=${tmux_conf_theme_window_status_activity_attr:-underscore} # tmux setw -g window-status-activity-style "fg=$tmux_conf_theme_window_status_activity_fg,bg=$tmux_conf_theme_window_status_activity_bg,$tmux_conf_theme_window_status_activity_attr" # -# tmux_conf_theme_window_status_bell_fg=${tmux_conf_theme_window_status_bell_fg:-'#ffff00'} # yellow -# tmux_conf_theme_window_status_bell_bg=${tmux_conf_theme_window_status_bell_bg:-'default'} -# tmux_conf_theme_window_status_bell_attr=${tmux_conf_theme_window_status_bell_attr:-'blink,bold'} +# tmux_conf_theme_window_status_bell_fg=${tmux_conf_theme_window_status_bell_fg:-#ffff00} # yellow +# tmux_conf_theme_window_status_bell_bg=${tmux_conf_theme_window_status_bell_bg:-default} +# tmux_conf_theme_window_status_bell_attr=${tmux_conf_theme_window_status_bell_attr:-blink,bold} # tmux setw -g window-status-bell-style "fg=$tmux_conf_theme_window_status_bell_fg,bg=$tmux_conf_theme_window_status_bell_bg,$tmux_conf_theme_window_status_bell_attr" # -# tmux_conf_theme_window_status_last_fg=${tmux_conf_theme_window_status_last_fg:-'#00afff'} # light blue -# tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-'default'} -# tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-'none'} +# tmux_conf_theme_window_status_last_fg=${tmux_conf_theme_window_status_last_fg:-#00afff} # light blue +# tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-default} +# tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-none} # tmux setw -g window-status-last-style "fg=$tmux_conf_theme_window_status_last_fg,bg=$tmux_conf_theme_window_status_last_bg,$tmux_conf_theme_window_status_last_attr" # # # -- indicators # -# tmux_conf_theme_pairing=${tmux_conf_theme_pairing:-'👓'} # U+1F453 -# tmux_conf_theme_pairing_fg=${tmux_conf_theme_pairing_fg:-'#e4e4e4'} # white -# tmux_conf_theme_pairing_bg=${tmux_conf_theme_pairing_bg:-'none'} -# tmux_conf_theme_pairing_attr=${tmux_conf_theme_pairing_attr:-'none'} +# tmux_conf_theme_pairing=${tmux_conf_theme_pairing:-👓 } # U+1F453 +# tmux_conf_theme_pairing_fg=${tmux_conf_theme_pairing_fg:-#e4e4e4} # white +# tmux_conf_theme_pairing_bg=${tmux_conf_theme_pairing_bg:-none} +# tmux_conf_theme_pairing_attr=${tmux_conf_theme_pairing_attr:-none} # -# tmux_conf_theme_prefix=${tmux_conf_theme_prefix:-'⌨'} # U+2328 -# tmux_conf_theme_prefix_fg=${tmux_conf_theme_prefix_fg:-'#e4e4e4'} # white -# tmux_conf_theme_prefix_bg=${tmux_conf_theme_prefix_bg:-'none'} -# tmux_conf_theme_prefix_attr=${tmux_conf_theme_prefix_attr:-'none'} +# tmux_conf_theme_prefix=${tmux_conf_theme_prefix:-⌨ } # U+2328 +# tmux_conf_theme_prefix_fg=${tmux_conf_theme_prefix_fg:-#e4e4e4} # white +# tmux_conf_theme_prefix_bg=${tmux_conf_theme_prefix_bg:-none} +# tmux_conf_theme_prefix_attr=${tmux_conf_theme_prefix_attr:-none} # -# tmux_conf_theme_root=${tmux_conf_theme_root:-'!'} -# tmux_conf_theme_root_fg=${tmux_conf_theme_root_fg:-'none'} -# tmux_conf_theme_root_bg=${tmux_conf_theme_root_bg:-'none'} -# tmux_conf_theme_root_attr=${tmux_conf_theme_root_attr:-'bold,blink'} +# tmux_conf_theme_root=${tmux_conf_theme_root:-!} +# tmux_conf_theme_root_fg=${tmux_conf_theme_root_fg:-none} +# tmux_conf_theme_root_bg=${tmux_conf_theme_root_bg:-none} +# tmux_conf_theme_root_attr=${tmux_conf_theme_root_attr:-bold,blink} # -# tmux_conf_theme_synchronized=${tmux_conf_theme_synchronized:-'🔒'} # U+1F512 -# tmux_conf_theme_synchronized_fg=${tmux_conf_theme_synchronized_fg:-'none'} -# tmux_conf_theme_synchronized_bg=${tmux_conf_theme_synchronized_bg:-'none'} -# tmux_conf_theme_synchronized_attr=${tmux_conf_theme_synchronized_attr:-'none'} +# tmux_conf_theme_synchronized=${tmux_conf_theme_synchronized:-🔒} # U+1F512 +# tmux_conf_theme_synchronized_fg=${tmux_conf_theme_synchronized_fg:-none} +# tmux_conf_theme_synchronized_bg=${tmux_conf_theme_synchronized_bg:-none} +# tmux_conf_theme_synchronized_attr=${tmux_conf_theme_synchronized_attr:-none} # # # -- status left style # -# tmux_conf_theme_status_left=${tmux_conf_theme_status_left-' ❐ #S '} -# tmux_conf_theme_status_left_fg=${tmux_conf_theme_status_left_fg:-'#000000,#e4e4e4,#e4e4e4'} # black, white , white -# tmux_conf_theme_status_left_bg=${tmux_conf_theme_status_left_bg:-'#ffff00,#ff00af,#00afff'} # yellow, pink, white blue -# tmux_conf_theme_status_left_attr=${tmux_conf_theme_status_left_attr:-'bold,none,none'} +# tmux_conf_theme_status_left=${tmux_conf_theme_status_left-' ❐ #S | ↑#{?uptime_y, #{uptime_y}y,}#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} '} +# tmux_conf_theme_status_left_fg=${tmux_conf_theme_status_left_fg:-#000000,#e4e4e4,#e4e4e4} # black, white , white +# tmux_conf_theme_status_left_bg=${tmux_conf_theme_status_left_bg:-#ffff00,#ff00af,#00afff} # yellow, pink, white blue +# tmux_conf_theme_status_left_attr=${tmux_conf_theme_status_left_attr:-bold,none,none} # # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ # -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g") @@ -1009,9 +1009,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # -- status right style # # tmux_conf_theme_status_right=${tmux_conf_theme_status_right-'#{pairing}#{prefix} #{battery_status} #{battery_bar} #{battery_percentage} , %R , %d %b | #{username} | #{hostname} '} -# tmux_conf_theme_status_right_fg=${tmux_conf_theme_status_right_fg:-'#8a8a8a,#e4e4e4,#000000'} # light gray, white, black -# tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-'#080808,#d70000,#e4e4e4'} # dark gray, red, white -# tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-'none,none,bold'} +# tmux_conf_theme_status_right=${tmux_conf_theme_status_right-'#{prefix}#{pairing}#{synchronized} #{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} '} +# tmux_conf_theme_status_right_fg=${tmux_conf_theme_status_right_fg:-#8a8a8a,#e4e4e4,#000000} # light gray, white, black +# tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-#080808,#d70000,#e4e4e4} # dark gray, red, white +# tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-none,none,bold} # # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ # -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g") @@ -1089,14 +1090,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # tmux set -g '@root' "$tmux_conf_theme_root" # -# tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-'◼'} -# tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-'◻'} -# tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-'auto'} -# tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-'gradient'} -# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-'gradient'} # red, orange, green -# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-'gradient'} # red, orange, green -# tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-'↑'} # U+2191 -# tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-'↓'} # U+2193 +# tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-◼} +# tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-◻} +# tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-auto} +# tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-gradient} +# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-gradient} # red, orange, green +# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-gradient} # red, orange, green +# tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-↑} # U+2191 +# tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-↓} # U+2193 # # case "$status_left $status_right" in # *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) @@ -1178,8 +1179,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # # -- clock ------------------------------------------------------------- # -# tmux_conf_theme_clock_colour=${tmux_conf_theme_clock_colour:-'#00afff'} # light blue -# tmux_conf_theme_clock_style=${tmux_conf_theme_clock_style:-'24'} +# tmux_conf_theme_clock_colour=${tmux_conf_theme_clock_colour:-#00afff} # light blue +# tmux_conf_theme_clock_style=${tmux_conf_theme_clock_style:-24} # tmux setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\ # setw -g clock-mode-style "$tmux_conf_theme_clock_style" # } From 5cc1fe9a12553099bf4147c16b7a5eeb7495a6b4 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 7 May 2019 20:28:28 +0200 Subject: [PATCH 02/28] removed subshell invocations from _is_enabled() --- .tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index dde6fdc..3783148 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -192,7 +192,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ' # # _is_enabled() { -# ( ([ x"$1" = x"enabled" ] || [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ]) && return 0 ) || return 1 +# [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"enabled" ] || [ x"$1" = x"1" ] # } # # _circled() { From 9b5f5155b3e1bfb813458923d4e84f4c6b696d03 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 7 May 2019 21:48:24 +0200 Subject: [PATCH 03/28] updated _apply_configuration() to redact tmux_conf_ variables from environment in a single call --- .tmux.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index 3783148..332a1f3 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1216,7 +1216,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # _apply_overrides # _apply_bindings # _apply_theme -# for name in $(printenv | grep -E -o '^tmux_conf_[^=]+'); do tmux setenv -gu "$name"; done; +# # shellcheck disable=SC2046 +# tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}') # } # # _urlview() { From 71d5e1caa1478928c4a6f57f6e4ad6a3aaddfa14 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 13:00:08 +0200 Subject: [PATCH 04/28] sent polyglot heredoc to ':' instead of 'cat > /dev/null' forking to cat, just to write to /dev/null is wasteful --- .tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index 332a1f3..e38fd02 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,4 +1,4 @@ -# cat << EOF > /dev/null +# : << EOF # https://github.com/gpakosz/.tmux # (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license, # without any warranty. From cba2a6c1ec183b23a35ecc2e413d1a95aeb12903 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 13:06:15 +0200 Subject: [PATCH 05/28] added _uname_s global variable --- .tmux.conf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index e38fd02..af1e18b 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -191,6 +191,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # __newline=' # ' # +# _uname_s=$(uname -s) +# # _is_enabled() { # [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"enabled" ] || [ x"$1" = x"1" ] # } @@ -255,8 +257,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # _battery() { # count=0 # charge=0 -# uname_s=$(uname -s) -# case "$uname_s" in +# case "$_uname_s" in # *Darwin*) # while IFS= read -r line; do # if [ x"$discharging" != x"true" ]; then @@ -472,7 +473,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # _tty_info() { # tty="${1##/dev/}" -# uname -s | grep -q "CYGWIN" && cygwin=true +# case "$_uname_s" in +# *CYGWIN*) +# cygwin=true +# ;; +# esac # # if [ x"$cygwin" = x"true" ]; then # ps -af | tail -n +2 | awk -v tty="$tty" ' @@ -592,7 +597,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _uptime() { -# case $(uname -s) in +# case "$_uname_s" in # *Darwin*) # boot=$(sysctl -q -n kern.boottime | awk -F'[ ,:]+' '{ print $4 }') # now=$(date +%s) @@ -626,7 +631,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _loadavg() { -# case $(uname -s) in +# case "$_uname_s" in # *Darwin*) # tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f2)" # ;; From 94eab29107c817bbfba3c4a652b6d119f18f58b1 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 16:04:53 +0200 Subject: [PATCH 06/28] made battery status update at most every minute also, stopped updating when no client is attached --- .tmux.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index af1e18b..834de15 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1127,7 +1127,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\ # set -g '@battery_status_charging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_charging")" \;\ # set -g '@battery_status_discharging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging")" -# status_right="#(cut -c3- ~/.tmux.conf | sh -s _battery)$status_right" +# interval=60 +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _battery; sleep $interval; done)$status_right" # ;; # esac # From 8a5ae4f9fcd0e08a82a0405c8027e9d9e6252129 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 16:06:23 +0200 Subject: [PATCH 07/28] made uptime status update at most every minute or every 'status-interval' seconds depending on whether '#{uptime_s}' is being used also, stopped updating when no client is attached --- .tmux.conf | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index 834de15..c4e9851 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1164,7 +1164,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \ # -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \ # -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g') -# status_right="#(cut -c3- ~/.tmux.conf | sh -s _uptime)$status_right" +# interval=60 +# case "$status_left $status_right" in +# *'#{@uptime_s}'*) +# interval=$(tmux show -gv status-interval) +# ;; +# esac +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" # ;; # esac # From 3676bfc6484fd44d186c1a8dc50c86b444259dba Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 16:07:56 +0200 Subject: [PATCH 08/28] made loadavg status update at most every 'status-interval' seconds also, stopped updating when no client is attached --- .tmux.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index c4e9851..c348ebe 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1181,7 +1181,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # status_right=$(echo "$status_right" | sed -E \ # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') -# status_right="#(cut -c3- ~/.tmux.conf | sh -s _loadavg)$status_right" +# interval=$(tmux show -gv status-interval) +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" # ;; # esac # From 5447e9fbf5b95d07ac7d8e5e3754a9789497d79a Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 28 Jul 2019 16:10:41 +0200 Subject: [PATCH 09/28] made theme settings apply in background to speed up startup time --- .tmux.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index c348ebe..24f130f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1230,10 +1230,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # # _apply_overrides -# _apply_bindings -# _apply_theme +# _apply_theme& +# _apply_bindings& # # shellcheck disable=SC2046 # tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}') +# wait # } # # _urlview() { From f657d6959c1ef425667b8c4e1cf38571e2ff9c60 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Wed, 21 Aug 2019 22:10:18 +0200 Subject: [PATCH 10/28] made battery, loadavg and uptime update with low process priority --- .tmux.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 24f130f..e2e3cb5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1129,7 +1129,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # set -g '@battery_status_discharging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging")" # interval=60 # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _battery; sleep $interval; done)$status_right" +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery; sleep $interval; done)$status_right" # ;; # esac # @@ -1171,7 +1171,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" # ;; # esac # @@ -1183,7 +1183,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # interval=$(tmux show -gv status-interval) # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" +# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" # ;; # esac # From f54cede3680d935817da5356f5e1582c819e37ac Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Wed, 18 Sep 2019 23:17:04 +0200 Subject: [PATCH 11/28] pass $tmux_conf_theme_root to the _root() helper instead of using a tmux variable --- .tmux.conf | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index e2e3cb5..38cdf13 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -587,13 +587,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # _root() { # tty=${1:-$(tmux display -p '#{pane_tty}')} +# root=$2 +# # username=$(_username "$tty" false) # -# if [ x"$username" = x"root" ]; then -# tmux show -gqv '@root' -# else -# echo "" -# fi +# [ x"$username" = x"root" ] && echo "$root" # } # # _uptime() { @@ -938,7 +936,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") # # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} #D)#[inherit]%g") +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ # -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") @@ -1026,7 +1024,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") # # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} #D)#[inherit]%g") +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ # -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") @@ -1093,8 +1091,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # # -- variables # -# tmux set -g '@root' "$tmux_conf_theme_root" -# # tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-◼} # tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-◻} # tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-auto} From 89bc03c61264947fd8e3b5835263691c55bfd31d Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 22 Sep 2019 14:20:41 +0200 Subject: [PATCH 12/28] made use of #{==:a,b} to implement #{root} when available compare the output of _username() to 'root' instead of deferring to the _root() helper --- .tmux.conf | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 38cdf13..a0482fc 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -552,7 +552,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # fi # -# printf '%s' "$username" +# printf '%s\n' "$username" # } # # _hostname() { @@ -582,7 +582,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # fi # -# printf '%s' "$hostname" +# printf '%s\n' "$hostname" # } # # _root() { @@ -935,8 +935,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ # -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") # -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# if [ -n "$(tmux display -p '#{version}')" ]; then +# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") +# else +# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# fi # # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ # -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") @@ -1023,8 +1028,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ # -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") # -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# if [ -n "$(tmux display -p '#{version}')" ]; then +# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") +# else +# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") +# fi # # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ # -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") From d6ea9ad9c7a3a9eaeede33a5ace217d80cf8c87b Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 22 Sep 2019 15:40:35 +0200 Subject: [PATCH 13/28] split _battery() into _battery_status() and _battery_bar() to refresh #{battery_status} more quickly --- .tmux.conf | 45 +++++++++++++++++++++++++++++++++------------ .tmux.conf.local | 5 ++--- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index a0482fc..2fe8e9f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -254,7 +254,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # display "mouse: $new" # } # -# _battery() { +# _battery_info() { # count=0 # charge=0 # case "$_uname_s" in @@ -301,7 +301,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }') # count=$((count + 1)) # done << EOF -# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining | tr -d '\r' | tail -n +2) +# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining 2> /dev/null | tr -d '\r' | tail -n +2 || true) # EOF # ;; # *OpenBSD*) @@ -319,10 +319,31 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # done # ;; # esac -# [ "$count" -ne 0 ] && charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }') -# if [ "$charge" -eq 0 ]; then -# tmux set -ug '@battery_status' \;\ -# set -ug '@battery_bar' \;\ +# [ "$count" -ne 0 ] && charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }') || true +# } +# +# _battery_status() { +# _battery_info +# if [ "$charge" = 0 ]; then +# tmux set -ug '@battery_status' +# return +# fi +# +# battery_status_charging=$1 +# battery_status_discharging=$2 +# if [ x"$discharging" = x"true" ]; then +# battery_status="$battery_status_discharging" +# else +# battery_status="$battery_status_charging" +# fi +# +# tmux set -g '@battery_status' "$battery_status" +# } +# +# _battery_bar() { +# _battery_info +# if [ "$charge" = 0 ]; then +# tmux set -ug '@battery_bar' \;\ # set -ug '@battery_hbar' \;\ # set -ug '@battery_vbar' \;\ # set -ug '@battery_percentage' @@ -543,9 +564,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 -# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }') +# username=$(command ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }') # # shellcheck disable=SC2086 -# [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') +# [ -z "$username" ] && username=$(command ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') # else # if ! _is_enabled "$ssh_only"; then # username=$(printf '%s' "$tty_info" | cut -d' ' -f2) @@ -1130,12 +1151,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\ # set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\ # set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\ -# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\ -# set -g '@battery_status_charging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_charging")" \;\ -# set -g '@battery_status_discharging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging")" +# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" +# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "$tmux_conf_battery_status_charging") +# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging") # interval=60 # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery; sleep $interval; done)$status_right" +# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar; sleep $interval; done)$status_right" # ;; # esac # diff --git a/.tmux.conf.local b/.tmux.conf.local index 53b94c7..069d81b 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -251,9 +251,8 @@ tmux_conf_battery_vbar_palette='gradient' # symbols used to indicate whether battery is charging or discharging tmux_conf_battery_status_charging='↑' # U+2191 tmux_conf_battery_status_discharging='↓' # U+2193 -#tmux_conf_battery_status_charging='⚡ ' # U+26A1 -#tmux_conf_battery_status_charging='🔌 ' # U+1F50C -#tmux_conf_battery_status_discharging='🔋 ' # U+1F50B +#tmux_conf_battery_status_charging='🔌' # U+1F50C +#tmux_conf_battery_status_discharging='🔋' # U+1F50B # clock style (when you hit + t) # you may want to use %I:%M %p in place of %R in tmux_conf_theme_status_right From cdda729983f107dd71708a2da48b09ed17eee872 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 22 Sep 2019 15:48:59 +0200 Subject: [PATCH 14/28] made _ssh_or_mosh_args() consume output of _tty_info() directly --- .tmux.conf | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 2fe8e9f..e89d9e8 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -546,7 +546,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _ssh_or_mosh_args() { -# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1=""; print $0; exit }') +# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }') # if [ -z "$args" ]; then # args=$(printf '%s' "$1" | grep 'mosh-client' | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') # fi @@ -559,14 +559,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_only=$2 # # tty_info=$(_tty_info "$tty") -# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-) # -# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") +# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 -# username=$(command ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }') +# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }') # # shellcheck disable=SC2086 -# [ -z "$username" ] && username=$(command ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') +# [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') # else # if ! _is_enabled "$ssh_only"; then # username=$(printf '%s' "$tty_info" | cut -d' ' -f2) @@ -581,9 +580,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_only=$2 # # tty_info=$(_tty_info "$tty") -# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-) # -# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") +# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 # hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^hostname / { print $2 }') From 03d9514071e6079a541a10f84c3f4bda48a74e52 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Wed, 25 Sep 2019 23:40:50 +0200 Subject: [PATCH 15/28] optimized _username() and _hostname() by removing some calls to external programs --- .tmux.conf | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index e89d9e8..4b9d855 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -563,12 +563,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 -# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }') +# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }') # # shellcheck disable=SC2086 # [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') # else # if ! _is_enabled "$ssh_only"; then -# username=$(printf '%s' "$tty_info" | cut -d' ' -f2) +# username="${tty_info#* }" +# username="${username%% *}" # fi # fi # @@ -584,20 +585,21 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 -# hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^hostname / { print $2 }') +# hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }') # # shellcheck disable=SC2086 # [ -z "$hostname" ] && hostname=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%hostname%% %h >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%hostname% / { print $2; exit }') -# #shellcheck disable=SC1004 -# hostname=$(echo "$hostname" | awk '\ -# { \ -# if ($1~/^[0-9.:]+$/) \ -# print $1; \ -# else \ -# split($1, a, ".") ; print a[1] \ -# }') +# +# case "$hostname" in +# *[a-z-].*) +# hostname=${hostname%%.*} +# ;; +# 127.0.0.1) +# hostname="localhost" +# ;; +# esac # else # if ! _is_enabled "$ssh_only"; then -# hostname=$(command hostname -s) +# hostname=$3 # fi # fi # @@ -864,9 +866,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \ -# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ -# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # tmux set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")" # # tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-#8a8a8a} # white @@ -888,16 +890,16 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \ -# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ -# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # tmux_conf_theme_window_status_current_format=$(echo "$tmux_conf_theme_window_status_current_format" | sed \ # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \ -# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ -# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # # tmux setw -g window-status-style "fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr" \;\ # setw -g window-status-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_format")" \;\ @@ -1162,14 +1164,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*) # status_left=$(echo "$status_left" | sed \ # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \ -# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ -# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # status_right=$(echo "$status_right" | sed \ # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \ -# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ -# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g') +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # ;; # esac # From 20fa97e310f0e98d259182bb47c88d4e159cb6bb Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Thu, 26 Sep 2019 13:45:35 +0200 Subject: [PATCH 16/28] optimized _ssh_or_mosh_args() by deferring calls to external programs --- .tmux.conf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 4b9d855..e409b52 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -546,10 +546,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _ssh_or_mosh_args() { -# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }') -# if [ -z "$args" ]; then -# args=$(printf '%s' "$1" | grep 'mosh-client' | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') -# fi +# case "$1" in +# *ssh*) +# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }') +# ;; +# *mosh-client*) +# args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') +# ;; +# esac # # printf '%s' "$args" # } From 7d02a72a466ceb493ec6a27598bc09363a13b528 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 27 Sep 2019 21:41:54 +0200 Subject: [PATCH 17/28] rewrote _apply_theme() to minimize the number of external calls --- .tmux.conf | 157 +++++++++++++++++++++++------------------------------ 1 file changed, 67 insertions(+), 90 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index e409b52..11a7bc8 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -802,15 +802,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_focused_pane_fg=${tmux_conf_theme_focused_pane_fg:-default} # default # tmux_conf_theme_focused_pane_bg=${tmux_conf_theme_focused_pane_bg:-#0087d7} # light blue # -# # tmux 1.9 doesn't really like set -q -# if tmux show -g -w | grep -q window-style; then -# tmux setw -g window-style "fg=$tmux_conf_theme_window_fg,bg=$tmux_conf_theme_window_bg" -# -# if _is_enabled "$tmux_conf_theme_highlight_focused_pane"; then -# tmux setw -g window-active-style "fg=$tmux_conf_theme_focused_pane_fg,bg=$tmux_conf_theme_focused_pane_bg" -# else -# tmux setw -g window-active-style default -# fi +# window_style="fg=$tmux_conf_theme_window_fg,bg=$tmux_conf_theme_window_bg" +# if _is_enabled "$tmux_conf_theme_highlight_focused_pane"; then +# window_active_style="fg=$tmux_conf_theme_focused_pane_fg,bg=$tmux_conf_theme_focused_pane_bg" +# else +# window_active_style="default" # fi # # tmux_conf_theme_pane_border_style=${tmux_conf_theme_pane_border_style:-thin} @@ -828,13 +824,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-default} # ;; # esac -# tmux setw -g pane-border-style "fg=$tmux_conf_theme_pane_border_fg,bg=$tmux_conf_theme_pane_border_bg" \; set -g pane-active-border-style "fg=$tmux_conf_theme_pane_active_border_fg,bg=$tmux_conf_theme_pane_active_border_bg" # # tmux_conf_theme_pane_indicator=${tmux_conf_theme_pane_indicator:-#00afff} # light blue # tmux_conf_theme_pane_active_indicator=${tmux_conf_theme_pane_active_indicator:-#00afff} # light blue # -# tmux set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator" -# # # -- status line ------------------------------------------------------- # # tmux_conf_theme_left_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_main-}") @@ -845,24 +838,18 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-#000000} # black # tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-#ffff00} # yellow # tmux_conf_theme_message_attr=${tmux_conf_theme_message_attr:-bold} -# tmux set -g message-style "fg=$tmux_conf_theme_message_fg,bg=$tmux_conf_theme_message_bg,$tmux_conf_theme_message_attr" # # tmux_conf_theme_message_command_fg=${tmux_conf_theme_message_command_fg:-#ffff00} # yellow # tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-#000000} # black # tmux_conf_theme_message_command_attr=${tmux_conf_theme_message_command_attr:-bold} -# tmux set -g message-command-style "fg=$tmux_conf_theme_message_command_fg,bg=$tmux_conf_theme_message_command_bg,$tmux_conf_theme_message_command_attr" # # tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-#000000} # black # tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-#ffff00} # yellow # tmux_conf_theme_mode_attr=${tmux_conf_theme_mode_attr:-bold} -# tmux setw -g mode-style "fg=$tmux_conf_theme_mode_fg,bg=$tmux_conf_theme_mode_bg,$tmux_conf_theme_mode_attr" # # tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-#8a8a8a} # white # tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-#080808} # dark gray # tmux_conf_theme_status_attr=${tmux_conf_theme_status_attr:-none} -# tmux set -g status-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ -# set -g status-left-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ -# set -g status-right-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" # # tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-#h ❐ #S ● #I #W} # @@ -873,7 +860,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #h #D)%g' \ # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') -# tmux set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")" # # tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-#8a8a8a} # white # tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-#080808} # dark gray @@ -905,25 +891,17 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \ # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #h #D)%g') # -# tmux setw -g window-status-style "fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr" \;\ -# setw -g window-status-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_format")" \;\ -# setw -g window-status-current-style "fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr" \;\ -# setw -g window-status-current-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_current_format")" -# # tmux_conf_theme_window_status_activity_fg=${tmux_conf_theme_window_status_activity_fg:-default} # tmux_conf_theme_window_status_activity_bg=${tmux_conf_theme_window_status_activity_bg:-default} # tmux_conf_theme_window_status_activity_attr=${tmux_conf_theme_window_status_activity_attr:-underscore} -# tmux setw -g window-status-activity-style "fg=$tmux_conf_theme_window_status_activity_fg,bg=$tmux_conf_theme_window_status_activity_bg,$tmux_conf_theme_window_status_activity_attr" # # tmux_conf_theme_window_status_bell_fg=${tmux_conf_theme_window_status_bell_fg:-#ffff00} # yellow # tmux_conf_theme_window_status_bell_bg=${tmux_conf_theme_window_status_bell_bg:-default} # tmux_conf_theme_window_status_bell_attr=${tmux_conf_theme_window_status_bell_attr:-blink,bold} -# tmux setw -g window-status-bell-style "fg=$tmux_conf_theme_window_status_bell_fg,bg=$tmux_conf_theme_window_status_bell_bg,$tmux_conf_theme_window_status_bell_attr" # # tmux_conf_theme_window_status_last_fg=${tmux_conf_theme_window_status_last_fg:-#00afff} # light blue # tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-default} # tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-none} -# tmux setw -g window-status-last-style "fg=$tmux_conf_theme_window_status_last_fg,bg=$tmux_conf_theme_window_status_last_bg,$tmux_conf_theme_window_status_last_attr" # # # -- indicators # @@ -954,31 +932,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_status_left_bg=${tmux_conf_theme_status_left_bg:-#ffff00,#ff00af,#00afff} # yellow, pink, white blue # tmux_conf_theme_status_left_attr=${tmux_conf_theme_status_left_attr:-bold,none,none} # -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g") -# -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") -# -# if [ -n "$(tmux display -p '#{version}')" ]; then -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") -# else -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") -# fi -# -# tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \ -# -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") -# # if [ -n "$tmux_conf_theme_status_left" ]; then -# status_left=$(awk \ +# status_left=$(printf '%s' "$tmux_conf_theme_status_left" | awk \ # -v fg_="$tmux_conf_theme_status_left_fg" \ # -v bg_="$tmux_conf_theme_status_left_bg" \ # -v attr_="$tmux_conf_theme_status_left_attr" \ # -v mainsep="$tmux_conf_theme_left_separator_main" \ # -v subsep="$tmux_conf_theme_left_separator_sub" ' -# function subsplit(s, l, i, a, r) +# function subsplit(s, l, i, a, r) # { # l = split(s, a, ",") # for (i = 1; i <= l; ++i) @@ -1031,10 +992,21 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # } # printf "#[fg=%s,bg=%s,none]%s", bg[j_], "default", mainsep -# }' << EOF -# $tmux_conf_theme_status_left -# EOF -# ) +# }') +# fi +# +# status_left=$(echo "$status_left" | sed \ +# -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g" \ +# -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g" \ +# -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g" \ +# -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g') +# +# if [ -n "$(tmux display -p '#{version}')" ]; then +# status_left=$(echo "$status_left" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") +# else +# status_left=$(echo "$status_left" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # status_left="$status_left " @@ -1047,31 +1019,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-#080808,#d70000,#e4e4e4} # dark gray, red, white # tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-none,none,bold} # -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g") -# -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g") -# -# if [ -n "$(tmux display -p '#{version}')" ]; then -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") -# else -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") -# fi -# -# tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \ -# -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g") -# # if [ -n "$tmux_conf_theme_status_right" ]; then -# status_right=$(awk \ +# status_right=$(printf '%s' "$tmux_conf_theme_status_right" | awk \ # -v fg_="$tmux_conf_theme_status_right_fg" \ # -v bg_="$tmux_conf_theme_status_right_bg" \ # -v attr_="$tmux_conf_theme_status_right_attr" \ # -v mainsep="$tmux_conf_theme_right_separator_main" \ # -v subsep="$tmux_conf_theme_right_separator_sub" ' -# function subsplit(s, l, i, a, r) +# function subsplit(s, l, i, a, r) # { # l = split(s, a, ",") # for (i = 1; i <= l; ++i) @@ -1118,10 +1073,21 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # j = j % l + 1 # } # } -# }' << EOF -# $tmux_conf_theme_status_right -# EOF -# ) +# }') +# fi +# +# status_right=$(echo "$status_right" | sed \ +# -e "s/#{pairing}/#[fg=$tmux_conf_theme_pairing_fg]#[bg=$tmux_conf_theme_pairing_bg]#[$tmux_conf_theme_pairing_attr]#{?session_many_attached,$tmux_conf_theme_pairing,}/g" \ +# -e "s/#{prefix}/#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[$tmux_conf_theme_prefix_attr]#{?client_prefix,$tmux_conf_theme_prefix,}/g" \ +# -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g" \ +# -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g') +# +# if [ -n "$(tmux display -p '#{version}')" ]; then +# status_right=$(echo "$status_right" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} #D),root},$tmux_conf_theme_root,}#[inherit]%g") +# else +# status_right=$(echo "$status_right" | sed \ +# -e "s%#{root}%#[fg=$tmux_conf_theme_root_fg]#[bg=$tmux_conf_theme_root_bg]#[$tmux_conf_theme_root_attr]#(cut -c3- ~/.tmux.conf | sh -s _root #{pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # # -- variables @@ -1149,15 +1115,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') -# -# tmux set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\ -# set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\ -# set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\ -# set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\ -# set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\ -# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" -# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "$tmux_conf_battery_status_charging") -# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging") # interval=60 # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true # status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar; sleep $interval; done)$status_right" @@ -1218,18 +1175,38 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # -# status_left=$(echo "$status_left" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g') -# status_right=$(echo "$status_right" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g') -# -# tmux set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\ -# set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")" -# # # -- clock ------------------------------------------------------------- # # tmux_conf_theme_clock_colour=${tmux_conf_theme_clock_colour:-#00afff} # light blue # tmux_conf_theme_clock_style=${tmux_conf_theme_clock_style:-24} -# tmux setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\ -# setw -g clock-mode-style "$tmux_conf_theme_clock_style" +# +# tmux setw -g window-style "$window_style" \; setw -g window-active-style "$window_active_style" \;\ +# setw -g pane-border-style "fg=$tmux_conf_theme_pane_border_fg,bg=$tmux_conf_theme_pane_border_bg" \; set -g pane-active-border-style "fg=$tmux_conf_theme_pane_active_border_fg,bg=$tmux_conf_theme_pane_active_border_bg" \;\ +# set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator" \;\ +# set -g message-style "fg=$tmux_conf_theme_message_fg,bg=$tmux_conf_theme_message_bg,$tmux_conf_theme_message_attr" \;\ +# set -g message-command-style "fg=$tmux_conf_theme_message_command_fg,bg=$tmux_conf_theme_message_command_bg,$tmux_conf_theme_message_command_attr" \;\ +# setw -g mode-style "fg=$tmux_conf_theme_mode_fg,bg=$tmux_conf_theme_mode_bg,$tmux_conf_theme_mode_attr" \;\ +# set -g status-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ +# set -g status-left-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ +# set -g status-right-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\ +# set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")" \;\ +# setw -g window-status-style "fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr" \;\ +# setw -g window-status-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_format")" \;\ +# setw -g window-status-current-style "fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr" \;\ +# setw -g window-status-current-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_current_format")" \;\ +# setw -g window-status-activity-style "fg=$tmux_conf_theme_window_status_activity_fg,bg=$tmux_conf_theme_window_status_activity_bg,$tmux_conf_theme_window_status_activity_attr" \;\ +# setw -g window-status-bell-style "fg=$tmux_conf_theme_window_status_bell_fg,bg=$tmux_conf_theme_window_status_bell_bg,$tmux_conf_theme_window_status_bell_attr" \;\ +# setw -g window-status-last-style "fg=$tmux_conf_theme_window_status_last_fg,bg=$tmux_conf_theme_window_status_last_bg,$tmux_conf_theme_window_status_last_attr" \;\ +# set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\ +# set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\ +# set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\ +# set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\ +# set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\ +# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\ +# set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\ +# set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")" \;\ +# setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\ +# setw -g clock-mode-style "$tmux_conf_theme_clock_style" # } # # _apply_configuration() { From 22de5533615d4671e95f2c5719ef540864bd4853 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 29 Sep 2019 13:14:37 +0200 Subject: [PATCH 18/28] optimized _tty_info() --- .tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index 11a7bc8..4fdb638 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -525,7 +525,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # else # ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk ' # NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) { -# user[$2] = $1; parent[$2] = $3; child[$3] = $2; for (i = 4 ; i <= NF; ++i) command[$2] = i > 4 ? command[$2] FS $i : $i +# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = $0 # } # END { # for (i in parent) From eae2cf27fb3cb3de19a43d6585872f051dc1de5d Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 20 Dec 2019 18:22:19 +0100 Subject: [PATCH 19/28] optimized _apply_theme() to launch background jobs straight from _apply_configuration() tmux doesn't share jobs between clients, and when multiple clients are attached the _load_avg(), _uptime() and _battery_bar() jobs get spawned once per client attached, which is wasteful --- .tmux.conf | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 4fdb638..e9e43d3 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -188,9 +188,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # fi # -# __newline=' -# ' -# # _uname_s=$(uname -s) # # _is_enabled() { @@ -350,25 +347,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # return # fi # -# variables=$(tmux show -gqv '@battery_bar_symbol_full' \;\ -# show -gqv '@battery_bar_symbol_empty' \;\ -# show -gqv '@battery_bar_length' \;\ -# show -gqv '@battery_bar_palette' \;\ -# show -gqv '@battery_hbar_palette' \;\ -# show -gqv '@battery_vbar_palette' \;\ -# show -gqv '@battery_status_charging' \;\ -# show -gqv '@battery_status_discharging') -# # shellcheck disable=SC2086 -# { set -f; IFS="$__newline"; set -- $variables; unset IFS; set +f; } -# # battery_bar_symbol_full=$1 # battery_bar_symbol_empty=$2 # battery_bar_length=$3 # battery_bar_palette=$4 # battery_hbar_palette=$5 # battery_vbar_palette=$6 -# battery_status_charging=$7 -# battery_status_discharging=$8 # # if [ x"$battery_bar_length" = x"auto" ]; then # columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80) @@ -379,12 +363,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # fi # -# if [ x"$discharging" = x"true" ]; then -# battery_status="$battery_status_discharging" -# else -# battery_status="$battery_status_charging" -# fi -# # if echo "$battery_bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then # # shellcheck disable=SC2086 # { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; } @@ -1092,14 +1070,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # # -- variables # -# tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-◼} -# tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-◻} +# tmux_conf_battery_bar_symbol_full=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_full:-◼}") +# tmux_conf_battery_bar_symbol_empty=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_empty:-◻}") # tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-auto} # tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-gradient} -# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-gradient} # red, orange, green -# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-gradient} # red, orange, green -# tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-↑} # U+2191 -# tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-↓} # U+2193 +# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-gradient} # red, orange, green +# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-gradient} # red, orange, green +# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191 +# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # # case "$status_left $status_right" in # *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) @@ -1116,8 +1094,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') # interval=60 -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true -# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar; sleep $interval; done)$status_right" +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true +# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" +# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" # ;; # esac # @@ -1159,7 +1138,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" +# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done" # ;; # esac # @@ -1171,7 +1150,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # interval=$(tmux show -gv status-interval) # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true -# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" +# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done" # ;; # esac # @@ -1197,12 +1176,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # setw -g window-status-activity-style "fg=$tmux_conf_theme_window_status_activity_fg,bg=$tmux_conf_theme_window_status_activity_bg,$tmux_conf_theme_window_status_activity_attr" \;\ # setw -g window-status-bell-style "fg=$tmux_conf_theme_window_status_bell_fg,bg=$tmux_conf_theme_window_status_bell_bg,$tmux_conf_theme_window_status_bell_attr" \;\ # setw -g window-status-last-style "fg=$tmux_conf_theme_window_status_last_fg,bg=$tmux_conf_theme_window_status_last_bg,$tmux_conf_theme_window_status_last_attr" \;\ -# set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\ -# set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\ -# set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\ -# set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\ -# set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\ -# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\ # set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\ # set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")" \;\ # setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\ From f7e383460d60bdd2950b69bea86dd5b36eb905e3 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 22 Dec 2019 10:35:42 +0100 Subject: [PATCH 20/28] moved pkill calls outside of case blocks otherwise if you change tmux_conf_theme_status_left or tmux_conf_theme_status_right and remove #{uptime_x}, #{loadavg} or #{battery_xxx} variables you end up with stray jobs running in the background --- .tmux.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index e9e43d3..2b09b13 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1079,6 +1079,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191 # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true # case "$status_left $status_right" in # *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) # status_left=$(echo "$status_left" | sed -E \ @@ -1094,7 +1095,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') # interval=60 -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true # tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" # status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" # ;; @@ -1115,6 +1115,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true # case "$status_left $status_right" in # *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*|*'#{uptime_s}'*) # status_left=$(echo "$status_left" | sed -E \ @@ -1137,11 +1138,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # interval=$(tmux show -gv status-interval) # ;; # esac -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true # tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done" # ;; # esac # +# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true # case "$status_left $status_right" in # *'#{loadavg}'*) # status_left=$(echo "$status_left" | sed -E \ @@ -1149,7 +1150,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # status_right=$(echo "$status_right" | sed -E \ # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # interval=$(tmux show -gv status-interval) -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true # tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done" # ;; # esac From 98c74671949d11b61ae519e4dd9a1dd70d6440e8 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Mon, 17 Feb 2020 20:20:19 +0100 Subject: [PATCH 21/28] launch _battery_bar() background job only if a battery is present --- .tmux.conf | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 2b09b13..567db7f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1080,25 +1080,28 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true -# case "$status_left $status_right" in -# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) -# status_left=$(echo "$status_left" | sed -E \ -# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ -# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ -# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ -# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ -# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') -# status_right=$(echo "$status_right" | sed -E \ -# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ -# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ -# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ -# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ -# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') -# interval=60 -# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" -# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" -# ;; -# esac +# _battery_info +# if [ "$charge" != 0 ]; then +# case "$status_left $status_right" in +# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) +# status_left=$(echo "$status_left" | sed -E \ +# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ +# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ +# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ +# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ +# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') +# status_right=$(echo "$status_right" | sed -E \ +# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ +# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ +# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ +# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ +# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') +# interval=60 +# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" +# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" +# ;; +# esac +# fi # # case "$status_left $status_right" in # *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*) From 74602e8d8dc1fc51e1c2c18423f4c43ed55d1fea Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 18 Feb 2020 21:22:29 +0100 Subject: [PATCH 22/28] implemented poor man's pkill --- .tmux.conf | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 567db7f..f9a2ed5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -209,6 +209,33 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # printf '%s' "$*" | perl -CS -pe 's/(\\u([0-9A-Fa-f]{1,4})|\\U([0-9A-Fa-f]{1,8}))/chr(hex($2.$3))/eg' 2>/dev/null # } # +# if command -v pkill > /dev/null 2>&1; then +# _pkillf() { +# pkill -f "$@" || true +# } +# else +# case "$_uname_s" in +# *CYGWIN*) +# _pkillf() { +# while IFS= read -r pid; do +# kill "$pid" || true +# done << EOF +# $(grep -Eao "$@" /proc/*/cmdline | xargs -0 | sed -E -n 's,/proc/([0-9]+)/.+$,\1,pg') +# EOF +# } +# ;; +# *) +# _pkillf() { +# while IFS= read -r pid; do +# kill "$pid" || true +# done << EOF +# $(ps -x -o pid= -o command= | grep -E "$@" | cut -d' ' -f1) +# EOF +# } +# ;; +# esac +# fi +# # _maximize_pane() { # current_session=${1:-$(tmux display -p '#{session_name}')} # current_pane=${2:-$(tmux display -p '#{pane_id}')} @@ -1079,7 +1106,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191 # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' # _battery_info # if [ "$charge" != 0 ]; then # case "$status_left $status_right" in @@ -1118,7 +1145,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' # case "$status_left $status_right" in # *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*|*'#{uptime_s}'*) # status_left=$(echo "$status_left" | sed -E \ @@ -1145,7 +1172,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' # case "$status_left $status_right" in # *'#{loadavg}'*) # status_left=$(echo "$status_left" | sed -E \ From 7a64679c2d9ed74aceefcb3ef444e5f31de6ffb5 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 26 Apr 2020 15:56:48 +0200 Subject: [PATCH 23/28] fixed #{username} being truncated under Cygwin --- .tmux.conf | 105 +++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index f9a2ed5..c6b5283 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -501,59 +501,57 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tty="${1##/dev/}" # case "$_uname_s" in # *CYGWIN*) -# cygwin=true +# ps -al | tail -n +2 | awk -v tty="$tty" ' +# ((/ssh/ && !/-W/) || !/ssh/) && $5 == tty { +# user[$1] = $6; parent[$1] = $2; child[$2] = $1 +# } +# END { +# for (i in parent) +# { +# j = i +# while (parent[j]) +# j = parent[j] +# +# if (!(i in child) && j != 1) +# { +# file = "/proc/" i "/cmdline"; getline command < file; close(file) +# gsub(/\0/, " ", command) +# "id -un " user[i] | getline username +# print i":"username":"command +# exit +# } +# } +# } +# ' +# ;; +# *) +# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk ' +# NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) { +# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4) +# } +# END { +# for (i in parent) +# { +# j = i +# while (parent[j]) +# j = parent[j] +# +# if (!(i in child) && j != 1) +# { +# print i":"user[i]":"command[i] +# exit +# } +# } +# } +# ' # ;; # esac -# -# if [ x"$cygwin" = x"true" ]; then -# ps -af | tail -n +2 | awk -v tty="$tty" ' -# ((/ssh/ && !/-W/) || !/ssh/) && $4 == tty { -# user[$2] = $1; parent[$2] = $3; child[$3] = $2 -# } -# END { -# for (i in parent) -# { -# j = i -# while (parent[j]) -# j = parent[j] -# -# if (!(i in child) && j != 1) -# { -# file = "/proc/" i "/cmdline"; getline command < file; close(file) -# gsub(/\0/, " ", command) -# print i, user[i], command -# exit -# } -# } -# } -# ' -# else -# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk ' -# NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) { -# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = $0 -# } -# END { -# for (i in parent) -# { -# j = i -# while (parent[j]) -# j = parent[j] -# -# if (!(i in child) && j != 1) -# { -# print i, user[i], command[i] -# exit -# } -# } -# } -# ' -# fi # } # # _ssh_or_mosh_args() { # case "$1" in # *ssh*) -# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }') +# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = ""; print $0; exit }') # ;; # *mosh-client*) # args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') @@ -568,8 +566,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_only=$2 # # tty_info=$(_tty_info "$tty") +# command=${tty_info#*:} +# command=${command#*:} # -# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") +# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 # username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }') @@ -577,8 +577,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }') # else # if ! _is_enabled "$ssh_only"; then -# username="${tty_info#* }" -# username="${username%% *}" +# username=${tty_info#*:} +# username=${username%%:*} # fi # fi # @@ -590,8 +590,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ssh_only=$2 # # tty_info=$(_tty_info "$tty") +# command=${tty_info#*:} +# command=${command#*:} # -# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info") +# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") # if [ -n "$ssh_or_mosh_args" ]; then # # shellcheck disable=SC2086 # hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }') @@ -677,7 +679,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # shift # # tty_info=$(_tty_info "$tty") -# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-) +# command=${tty_info#*:} +# command=${command#*:} # # case "$command" in # *mosh-client*) From cb2bd9f3787f17c335cacfc05ba8f2f6d8316d81 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 1 May 2020 13:46:03 +0200 Subject: [PATCH 24/28] made #{loadavg} work under Cygwin --- .tmux.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tmux.conf b/.tmux.conf index c6b5283..2d860ee 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -665,7 +665,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # *Darwin*) # tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f2)" # ;; -# *Linux*) +# *Linux*|*CYGWIN*) # tmux set -g @loadavg "$(cut -d' ' -f1 < /proc/loadavg)" # ;; # *OpenBSD*) From 9e25f3a5504eb8793c8b893a75b4e13d60c8dc1b Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Fri, 1 May 2020 22:24:41 +0200 Subject: [PATCH 25/28] fixed _apply_bindings() to support paths with spaces _split_window() needs to be given -c '#{pane_current_path}', properly quoted --- .tmux.conf | 60 +++++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 2d860ee..ccea561 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -712,51 +712,47 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # _apply_bindings() { # cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT # -# tmux list-keys | grep -vF 'tmux.conf.local' | grep -E '(new-window|split(-|_)window|new-session|copy-selection|copy-pipe)' > "$cfg" +# tmux list-keys | grep -vF 'tmux.conf.local' | grep -E 'new-window|split(-|_)window|new-session|copy-selection|copy-pipe' > "$cfg" # # # tmux 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the # # output of list-keys can be truncated # perl -p -i -e "s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}\"/g" "$cfg" # +# perl -p -i -e " +# s/\bnew-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/new-window\1/g +# ; +# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\}([^\n\1]*)(\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*)\1/run-shell \1cut -c3- ~\/.tmux.conf | sh -s _split_window #{pane_tty}\2\5\1/g +# ; +# s/\brun-shell\b(\s+((?:\\\\\")?|\"?|'?)cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+((?:\\\\\")?|\"?|'?)#\{pane_tty\}\3)(.*?)\2/split-window\4/g +# ; +# s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" \ +# "$cfg" +# # tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false} # if _is_enabled "$tmux_conf_new_window_retain_current_path"; then -# perl -p -i \ -# -e "s/\b(new-window)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \ -# -e ';' \ -# -e "s/\bnew-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/new-window -c '#{pane_current_path}'/g" \ +# perl -p -i -e " +# s/\bnew-window\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/ +# ; +# s/\bnew-window\b/new-window -c '#\{pane_current_path\}'/g" \ # "$cfg" -# else -# perl -p -i -e "s/\bnew-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" "$cfg" # fi # # tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true} -# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then -# perl -p -i -e "s/\bsplit-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/split-window -c '#{pane_current_path}'/g" "$cfg" -# else -# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" "$cfg" -# fi -# # tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false} # if _is_enabled "$tmux_conf_new_pane_reconnect_ssh"; then -# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then -# perl -p -i \ -# -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1\3 -c #\{pane_current_path\}'/g" \ -# -e ';' \ -# -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1 -c \\\\\"#{pane_current_path}\\\\\"\"/g" \ -# "$cfg" -# else -# perl -p -i \ -# -e "s/\bsplit-window\b([^;}\n]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1'/g" \ -# -e ';' \ -# -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1\"/g" \ -# "$cfg" -# fi -# else -# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then -# perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*?)\s+-c\s+#\{pane_current_path\}\2/split-window\3 -c '#{pane_current_path}'/g" "$cfg" -# else -# perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*)\2/split-window\3/g" "$cfg" -# fi +# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #\{pane_tty\}\1'/g" "$cfg" +# fi +# +# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then +# perl -p -i -e " +# s/\bsplit-window\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/ +# ; +# s/\bsplit-window\b/split-window -c '#{pane_current_path}'\1/g +# ; +# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window #\{pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\1'/g if /\bdisplay-menu\b/ +# ; +# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window #\{pane_tty\} -c \"#\{pane_current_path\}\"\1'/g" \ +# "$cfg" # fi # # tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false} From a8081d87befb0627d6906b7ca43aa567468e3a18 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Wed, 3 Jun 2020 20:06:56 +0200 Subject: [PATCH 26/28] fixed tmux_conf_new_window_retain_current_path and tmux_conf_new_pane_retain_current_path not working under Cygwin and MSYS2 --- .tmux.conf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.tmux.conf b/.tmux.conf index ccea561..8edd999 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1239,6 +1239,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # esac # fi # +# case "$_uname_s" in +# *CYGWIN*|*MSYS*) +# # prevent Cygwin and MSYS2 from cd-ing into home directory when evaluating /etc/profile +# tmux setenv -g CHERE_INVOKING 1 +# ;; +# esac +# # _apply_overrides # _apply_theme& # _apply_bindings& From d357ae54ee02f750e4d0687dd3f9e843fd047a99 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Thu, 23 Jul 2020 12:41:12 +0200 Subject: [PATCH 27/28] removed useless tests in _battery_info() --- .tmux.conf | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 8edd999..8f07d47 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -284,9 +284,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # case "$_uname_s" in # *Darwin*) # while IFS= read -r line; do -# if [ x"$discharging" != x"true" ]; then -# discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false") -# fi +# discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false") # percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%') # charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }') # count=$((count + 1)) @@ -298,9 +296,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # while IFS= read -r batpath; do # grep -i -q device "$batpath/scope" 2> /dev/null && continue # -# if [ x"$discharging" != x"true" ]; then -# discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false") -# fi +# discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false") # bat_capacity="$batpath/capacity" # if [ -r "$bat_capacity" ]; then # charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + capacity / 100 }') @@ -319,9 +315,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # *CYGWIN*|*MSYS*|*MINGW*) # while IFS= read -r line; do # [ -z "$line" ] && continue -# if [ x"$discharging" != x"true" ]; then -# discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }') -# fi +# discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }') # charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }') # count=$((count + 1)) # done << EOF @@ -331,9 +325,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # *OpenBSD*) # for batid in 0 1 2; do # sysctl -n "hw.sensors.acpibat$batid.raw0" 2>&1 | grep -q 'not found' && continue -# if [ x"$discharging" != x"true" ]; then -# discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false") -# fi +# discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false") # if sysctl -n "hw.sensors.acpibat$batid" | grep -q amphour; then # charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }') # else From 5d895f94b7c811f9599383b16c3f608bcb21bb44 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Thu, 23 Jul 2020 12:43:52 +0200 Subject: [PATCH 28/28] fixed _battery_info() not accommodating for empty lines, fixes #377 --- .tmux.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.tmux.conf b/.tmux.conf index 8f07d47..ee07a8a 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -284,6 +284,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # case "$_uname_s" in # *Darwin*) # while IFS= read -r line; do +# [ -z "$line" ] && continue # discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false") # percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%') # charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }') @@ -294,6 +295,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # *Linux*) # while IFS= read -r batpath; do +# [ -z "$batpath" ] && continue # grep -i -q device "$batpath/scope" 2> /dev/null && continue # # discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")