From 150323277382577f184e5cd87dfce2de5176264c Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sat, 3 Sep 2016 19:49:55 +0200 Subject: [PATCH] major rewrite, closes #10, #23, #30 and #31 - status-justify aware status line - flexible status line definition with many new variables/indicators: - #{battery_bar}, #{battery_vbar}, #{battery_percentage} - #{uptime_d}, #{uptime_h}, #{uptime_m}, #{uptime_s} - #{pairing}, #{prefix}, #{root} - #{username}, #{username_ssh}, #{hostname}, #{hostname_ssh} - ... - smart username and hostname variables: - detects root user - detects SSH sessions to remote servers - support for circled session names (when number) and window identifiers up to 20: - #{circled_session_name}, #{circled_window_index} - support for connecting to the same host when splitting a pane running an SSH session - support for 24b colours - support for OpenBSD (tested with OpenBSD 6.0) - cleaned everything with shellcheck --- .tmux.conf | 1057 ++++++++++++++++++++++++++++++++-------------- .tmux.conf.local | 322 +++++++++----- README.md | 265 ++++-------- 3 files changed, 1056 insertions(+), 588 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index cc733d3..2e96dcf 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,5 +1,8 @@ # cat << ►_◄ > /dev/null +# https://github.com/gpakosz/.tmux # (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz) +# /!\ do not edit this file +# instead, override settings in ~/.tmux.conf.local # -- general ------------------------------------------------------------------- @@ -14,6 +17,9 @@ set -s focus-events on set -g prefix2 C-a # GNU-Screen compatible prefix bind C-a send-prefix -2 +set -q -g status-utf8 on # expect UTF-8 (tmux < 2.2) +setw -q -g utf8 on + set -g history-limit 5000 # boost history # edit configuration @@ -23,7 +29,7 @@ bind e new-window -n '~/.tmux.conf.local' "sh -c '\${EDITOR:-vim} ~/.tmux.conf.l bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced' # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard -if 'which -s reattach-to-user-namespace' 'set -g default-command "exec initializing... 2> /dev/null & reattach-to-user-namespace $SHELL -l"' +if 'type -p reattach-to-user-namespace > /dev/null 2>&1' 'set -g default-command "exec $SHELL... 2> /dev/null & reattach-to-user-namespace $SHELL -l"' # -- display ------------------------------------------------------------------- @@ -32,8 +38,7 @@ set -g base-index 1 # start windows numbering at 1 setw -g pane-base-index 1 # make pane numbering consistent with windows setw -g automatic-rename on # rename window to reflect current program -# renumber windows when a window is closed -set -g renumber-windows on +set -g renumber-windows on # renumber windows when a window is closed set -g set-titles on # set terminal title set -g set-titles-string '#h ❐ #S ● #I #W' @@ -43,11 +48,8 @@ set -g display-time 1000 # slightly longer status messages display time set -g status-interval 10 # redraw status line every 10 seconds -# 24 hour clock -setw -g clock-mode-style 24 - # clear both screen and history -bind -n C-l send-keys C-l \; clear-history +bind -n C-l send-keys C-l \; run 'sleep 0.05 && tmux clear-history' # activity set -g monitor-activity on @@ -81,17 +83,17 @@ bind -r C-l next-window # select next window bind Tab last-window # move to last active window # toggle mouse -bind m run "cut -c3- ~/.tmux.conf | sh -s toggle_mouse" +bind m run "cut -c3- ~/.tmux.conf | sh -s _toggle_mouse" # -- urlview ------------------------------------------------------------------- -bind U run "cut -c3- ~/.tmux.conf | sh -s urlview #{pane_id}" +bind U run "cut -c3- ~/.tmux.conf | sh -s _urlview #{pane_id}" # -- facebook pathpicker ------------------------------------------------------- -bind F run "cut -c3- ~/.tmux.conf | sh -s fpp #{pane_id}" +bind F run "cut -c3- ~/.tmux.conf | sh -s _fpp #{pane_id}" # -- list choice --------------------------------------------------------------- @@ -132,17 +134,17 @@ bind -t vi-copy H start-of-line bind -t vi-copy L end-of-line # copy to Mac OSX pasteboard -if -b 'which -s reattach-to-user-namespace' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"' +if -b 'type -p reattach-to-user-namespace > /dev/null 2>&1' 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"' -# -- user defined -------------------------------------------------------------- +# -- user defined overrides ---------------------------------------------------- if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local' # -- 8< ------------------------------------------------------------------------ -run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' +run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # ►_◄ @@ -150,205 +152,57 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # # exit the script if any statement returns a non-true return value # set -e # -# apply_theme() { -# tmux_conf_theme=${tmux_conf_theme:-default} -# case "${tmux_conf_theme}" in -# powerline|powerline_patched_font) -# tmux_conf_theme_left_separator_main=${tmux_conf_theme_left_separator_main-''} -# tmux_conf_theme_left_separator_sub=${tmux_conf_theme_left_separator_sub-''} -# tmux_conf_theme_right_separator_main=${tmux_conf_theme_right_separator_sub-''} -# tmux_conf_theme_right_separator_sub=${tmux_conf_theme_right_separator_sub-''} -# ;; -# ""|default) -# tmux_conf_theme_left_separator_main=${tmux_conf_theme_left_separator_main-''} -# tmux_conf_theme_left_separator_sub=${tmux_conf_theme_left_separator_sub-'|'} -# tmux_conf_theme_right_separator_main=${tmux_conf_theme_right_separator_main-''} -# tmux_conf_theme_right_separator_sub=${tmux_conf_theme_right_separator_sub-'|'} -# ;; -# esac +# __newline=' +# ' # -# case "$tmux_conf_theme" in -# ""|default|powerline) -# -# # panes -# tmux_conf_theme_pane_border_fg=${tmux_conf_theme_pane_border_fg:-colour238} # light gray -# tmux_conf_theme_pane_active_border_fg=${tmux_conf_theme_pane_active_border_fg:-colour39} # light blue -# -# tmux set -g pane-border-style fg=$tmux_conf_theme_pane_border_fg \; set -g pane-active-border-style fg=$tmux_conf_theme_pane_active_border_fg -# #uncomment for fat borders -# #tmux set -ga pane-border-style bg=$tmux_conf_theme_pane_border_fg \; set -ga pane-active-border-style bg=$tmux_conf_theme_pane_active_border_fg -# -# tmux_conf_theme_display_panes_active_colour=${tmux_conf_theme_display_panes_active_colour:-colour39} # light blue -# tmux_conf_theme_display_panes_colour=${tmux_conf_theme_display_panes_colour:-colour39} # light blue -# tmux set -g display-panes-active-colour $tmux_conf_theme_display_panes_active_colour \; set -g display-panes-colour $tmux_conf_theme_display_panes_colour -# -# tmux_conf_theme_highlight_focused_pane=${tmux_conf_theme_highlight_focused_pane:-disabled} -# 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:-colour23} # dark blue/green -# highlight_focused_pane_enabled=$( ([ x"$tmux_conf_theme_highlight_focused_pane" = x"enabled" ] || [ -z "$tmux_conf_theme_highlight_focused_pane" ]) && echo "true" || echo "false" ) -# if [ x"$highlight_focused_pane_enabled" = x"true" ] ; 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 -# -# # messages -# tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-colour16} # black -# tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-colour226} # 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:-colour16} # black -# tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-colour160} # light yellow -# tmux set -g message-command-style fg=$tmux_conf_theme_message_command_fg,bg=$tmux_conf_theme_message_command_bg,$tmux_conf_theme_message_attr -# -# # windows mode -# tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-colour16} # black -# tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-colour226} # 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 -# -# # status line -# tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-colour253} # white -# tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-colour232} # dark gray -# tmux set -g status-style fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg -# -# tmux_conf_theme_session_fg=${tmux_conf_theme_session_fg:-colour16} # black -# tmux_conf_theme_session_bg=${tmux_conf_theme_session_bg:-colour226} # yellow -# status_left="#[fg=$tmux_conf_theme_session_fg,bg=$tmux_conf_theme_session_bg,bold] ❐ #S #[fg=$tmux_conf_theme_session_bg,bg=$tmux_conf_theme_status_bg,nobold]$tmux_conf_theme_left_separator_main" -# if [ x"`tmux -q -L tmux_theme_status_left_test -f /dev/null new-session -d \; show -g -v status-left \; kill-session`" = x"[#S] " ] ; then -# status_left="$status_left " -# fi -# tmux set -g status-left-length 32 \; set -g status-left "$status_left" -# -# tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-colour245} # light gray -# tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-colour232} # dark gray -# window_status_format="#I #W" -# tmux setw -g window-status-style fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg \; setw -g window-status-format "$window_status_format" -# -# tmux_conf_theme_window_status_current_fg=${tmux_conf_theme_window_status_current_fg:-colour16} # black -# tmux_conf_theme_window_status_current_bg=${tmux_conf_theme_window_status_current_bg:-colour39} # light blue -# window_status_current_format="#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_window_status_current_bg]$tmux_conf_theme_left_separator_main#[fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,bold] #I #W #[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_status_bg,nobold]$tmux_conf_theme_left_separator_main" -# tmux setw -g window-status-current-format "$window_status_current_format" -# tmux set -g status-justify left -# -# 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:-colour226} # 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 -# -# window_status_last_fg=colour39 # light blue -# window_status_last_attr=default -# tmux setw -g window-status-last-style $window_status_last_attr,fg=$window_status_last_fg -# -# tmux_conf_theme_prefix=${tmux_conf_theme_prefix:-disabled} -# tmux_conf_theme_battery=${tmux_conf_theme_battery:-enabled} -# tmux_conf_theme_time=${tmux_conf_theme_time:-enabled} -# tmux_conf_theme_date=${tmux_conf_theme_date:-enabled} -# tmux_conf_theme_username=${tmux_conf_theme_username:-enabled} -# tmux_conf_theme_hostname=${tmux_conf_theme_hostname:-enabled} -# -# prefix_enabled=$( ([ x"$tmux_conf_theme_prefix" = x"enabled" ] || [ -z "$tmux_conf_theme_prefix" ]) && echo "true" || echo "false" ) -# battery_enabled=$( ([ x"$tmux_conf_theme_battery" = x"enabled" ] || [ -z "$tmux_conf_theme_battery" ]) && echo "true" || echo "false" ) -# time_enabled=$( ([ x"$tmux_conf_theme_time" = x"enabled" ] || [ -z "$tmux_conf_theme_time" ]) && echo "true" || echo "false" ) -# date_enabled=$( ([ x"$tmux_conf_theme_date" = x"enabled" ] || [ -z "$tmux_conf_theme_date" ]) && echo "true" || echo "false" ) -# username_enabled=$( ([ x"$tmux_conf_theme_username" = x"enabled" ] || [ -z "$tmux_conf_theme_username" ] || ([ x"$tmux_conf_theme_username" = x"ssh" ] && ([ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] || [ -n "$SSH_TTY" ]))) && echo "true" || echo "false" ) -# hostname_enabled=$( ([ x"$tmux_conf_theme_hostname" = x"enabled" ] || [ -z "$tmux_conf_theme_hostname" ] || ([ x"$tmux_conf_theme_hostname" = x"ssh" ] && ([ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] || [ -n "$SSH_TTY" ]))) && echo "true" || echo "false" ) -# -# tmux_conf_theme_prefix_fg=${tmux_conf_theme_prefix_fg:-colour253} # white -# tmux_conf_theme_prefix_bg=${tmux_conf_theme_prefix_bg:-colour16} # black -# tmux_conf_theme_time_date_fg=${tmux_conf_theme_time_date_fg:-colour247} # light gray -# tmux_conf_theme_time_date_bg=${tmux_conf_theme_time_date_bg:-colour232} # dark gray -# tmux_conf_theme_username_fg=colour254 # white -# tmux_conf_theme_username_bg=colour160 # red -# tmux_conf_theme_hostname_fg=colour16 # black -# tmux_conf_theme_hostname_bg=colour254 # white -# -# if [ x"$prefix_enabled" = x"true" ] ; then -# status_right_prefix="#{?client_prefix,#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[bold]⌨ #[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_status_bg]#[nobold],}" -# fi -# if [ x"$battery_enabled" = x"true" ] ; then -# status_right_battery="${tmux_conf_battery:-#(cut -c3- ~/.tmux.conf | sh -s battery ${tmux_conf_battery_style:-bar} ${tmux_conf_battery_symbol:-block} ${tmux_conf_battery_symbol_count:-auto} \"${tmux_conf_battery_palette:-colour160,colour254,colour16}\" ${tmux_conf_battery_status:-enabled})} " -# has_battery=$(eval echo \$${status_right_battery#\#}) -# if [ -n "$has_battery" ] && ([ x"$time_enabled" = x"true" ] || [ x"$date_enabled" = x"true" ]) ; then -# status_right_battery="${status_right_battery}#[fg=$tmux_conf_theme_time_date_fg,nobold]$tmux_conf_theme_right_separator_sub" -# fi -# fi -# if [ x"$time_enabled" = x"true" ] ; then -# status_right_time="#[fg=$tmux_conf_theme_time_date_fg,nobold]${status_right_time} %R " -# if [ x"$date_enabled" = x"true" ] ; then -# status_right_time="${status_right_time}#[fg=$tmux_conf_theme_time_date_fg,nobold]$tmux_conf_theme_right_separator_sub" -# fi -# fi -# if [ x"$date_enabled" = x"true" ] ; then -# status_right_date="#[fg=$tmux_conf_theme_time_date_fg,nobold] %d %b " -# fi -# if [ x"$username_enabled" = x"true" ] ; then -# status_right_username="#[fg=$tmux_conf_theme_username_bg,bg=$tmux_conf_theme_time_date_bg,nobold]$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_username_fg,bg=$tmux_conf_theme_username_bg,nobold] #(whoami) " -# fi -# if [ x"$hostname_enabled" = x"true" ] ; then -# if [ x"$username_enabled" = x"true" ] ; then -# status_right_hostname="#[bg=$tmux_conf_theme_username_bg]" -# else -# status_right_hostname="#[bg=$tmux_conf_theme_time-data_bg]" -# fi -# status_right_hostname="#[fg=$tmux_conf_theme_hostname_bg,nobold]${status_right_hostname}$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_hostname_fg,bg=$tmux_conf_theme_hostname_bg,bold] #h " -# fi -# -# status_right="${status_right_prefix}${status_right_battery}${status_right_time}${status_right_date}${status_right_username}${status_right_hostname}" -# tmux set -g status-right-length 64 \; set -g status-right "$status_right" -# -# # clock -# clock_mode_colour=colour39 # light blue -# tmux setw -g clock-mode-colour $clock_mode_colour -# ;; -# esac +# _is_enabled() { +# ( ([ x"$1" = x"enabled" ] || [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ]) && return 0 ) || return 1 # } # -# circled_digit() { -# circled_digits='⓪①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳' -# if [ $1 -lt 20 ] 2>/dev/null ; then -# echo ${circled_digits:$1:1} +# _circled_digit() { +# circled_digits='⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳' +# if [ "$1" -le 20 ] 2>/dev/null; then +# i=$(( $1 + 1 )) +# eval set -- "$circled_digits" +# eval echo "\${$i}" # else -# echo $1 +# echo "$1" # fi # } # -# maximize_pane() { -# __current_pane=$(tmux display -p '#{pane_id}') +# _maximize_pane() { +# current_pane=$(tmux display -p '#{pane_id}') # -# __dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -o '^1 %.\+maximized.\+$' || true) -# __restore=$(echo "${__dead_panes}" | sed -n -E -e "s/^1 ${__current_pane} .+maximized.+(%[0-9]+)$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t ${__current_pane}/p" -e "s/^1 (%[0-9]+) .+maximized.+${__current_pane}$/tmux swap-pane -s \1 -t ${__current_pane} \; kill-pane -t \1/p" ) +# dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -o '^1 %.\+maximized.\+$' || true) +# restore=$(echo "$dead_panes" | sed -n -E -e "s/^1 $current_pane .+maximized.+(%[0-9]+)$/tmux swap-pane -s \1 -t $current_pane \; kill-pane -t $current_pane/p" -e "s/^1 (%[0-9]+) .+maximized.+$current_pane$/tmux swap-pane -s \1 -t $current_pane \; kill-pane -t \1/p" ) # -# if [ x"${__restore}" = x ] ; then -# [ x"$(tmux list-panes | wc -l | sed 's/^ *//g')" = x1 ] && tmux display "Can't maximize with only one pane" && return -# __window=$(tmux new-window -P "exec maximized...& tmux setw remain-on-exit on; clear; tmux clear-history; printf 'Pane has been maximized, press + to restore. %s' \\${__current_pane};") -# __window=${__window%.*} +# if [ -z "$restore" ]; then +# [ "$(tmux list-panes | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return +# window=$(tmux new-window -P "exec maximized... 2> /dev/null & tmux setw remain-on-exit on; printf 'Pane has been maximized, press + to restore. %s' \\$current_pane") +# window=${window%.*} # -# __guard=50 -# while ( [ x"$(tmux list-panes -t ${__window} -F '#{session_name}:#{window_index} #{pane_dead}')" != x"${__window} "1 ] && [ x"${__guard}" != x0 ] ) ; do sleep 0.01 ; __guard=$((__guard - 1)); done -# if [ x"${__guard}" = 0 ] ; then -# exit 1 +# guard=50 +# while [ x"$(tmux list-panes -t "$window" -F '#{session_name}:#{window_index} #{pane_dead}' 2>/dev/null)" != x"$window 1" ] && [ "$guard" -ne 0 ]; do +# sleep 0.01 +# guard=$((guard - 1)) +# done +# if [ "$guard" -eq 0 ]; then +# tmux display 'Unable to maximize pane' # fi # -# __new_pane=$(tmux display -p '#{pane_id}') -# tmux setw remain-on-exit off \; swap-pane -s "${__current_pane}" -t "${__new_pane}" +# new_pane=$(tmux display -p '#{pane_id}') +# tmux setw remain-on-exit off \; swap-pane -s "$current_pane" -t "$new_pane" # else -# ${__restore} || tmux kill-pane +# $restore || tmux kill-pane # fi # } # -# toggle_mouse() { -# if (tmux show -g -w |grep -q mode-mouse); then +# _toggle_mouse() { +# if tmux show -g -w | grep -q mode-mouse; then # old=$(tmux show -g -w | grep mode-mouse | cut -d' ' -f2) # new="" # -# if [ "$old" = "on" ] ; then +# if [ "$old" = "on" ]; then # new="off" # else # new="on" @@ -363,7 +217,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # old=$(tmux show -g | grep mouse | head -n 1 | cut -d' ' -f2) # new="" # -# if [ "$old" = "on" ] ; then +# if [ "$old" = "on" ]; then # new="off" # else # new="on" @@ -374,163 +228,742 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # fi # } # -# battery() { +# _battery() { # uname_s=$(uname -s) -# if [ x"$uname_s" = x"Darwin" ]; then -# batt=$(pmset -g batt) -# percentage=$(echo $batt |egrep -o [0-9]+%) || return -# discharging=$(echo $batt | grep -qi "discharging" && echo "true" || echo "false") -# charge="${percentage%%%} / 100" -# elif [ x"$uname_s" = x"Linux" ]; then -# batpath=/sys/class/power_supply/BAT0 -# if [ ! -d $batpath ]; then -# batpath=/sys/class/power_supply/BAT1 -# fi -# discharging=$(grep -qi "discharging" $batpath/status && echo "true" || echo "false") -# bat_capacity=$batpath/capacity -# bat_energy_full=$batpath/energy_full -# bat_energy_now=$batpath/energy_now -# if [ -r "$bat_capacity" ] ; then -# charge="$(cat $bat_capacity) / 100" -# else -# if [ ! -r "$bat_energy_full" -o ! -r "$bat_energy_now" ]; then -# return +# case "$uname_s" in +# *Darwin*) +# batt=$(pmset -g batt) +# percentage=$(echo "$batt" |egrep -o [0-9]+%) || return +# discharging=$(echo "$batt" | grep -qi "discharging" && echo "true" || echo "false") +# charge="${percentage%%%} / 100" +# ;; +# *Linux*) +# batpath=/sys/class/power_supply/BAT0 +# if [ ! -d $batpath ]; then +# batpath=/sys/class/power_supply/BAT1 # fi -# charge="$(cat $bat_energy_now) / $(cat $bat_energy_full)" || return -# fi -# elif [ x"${uname_s:0:6}" = x"CYGWIN" ]; then -# wmic path Win32_Battery 2>&1 | grep -q 'No Instance' && return -# discharging=$(wmic path Win32_Battery Get BatteryStatus 2>/dev/null | grep -q 1 && echo "true" || echo "false") -# percentage=$(wmic path Win32_Battery Get EstimatedChargeRemaining /format:list 2>/dev/null | grep '[^[:blank:]]' | cut -d= -f2) -# charge="${percentage} / 100" -# else -# return -# fi +# discharging=$(grep -qi "discharging" $batpath/status && echo "true" || echo "false") +# bat_capacity=$batpath/capacity +# bat_energy_full=$batpath/energy_full +# bat_energy_now=$batpath/energy_now +# if [ -r "$bat_capacity" ]; then +# charge="$(cat $bat_capacity) / 100" +# else +# if [ ! -r "$bat_energy_full" ] || [ ! -r "$bat_energy_now" ]; then +# return +# fi +# charge="$(cat $bat_energy_now) / $(cat $bat_energy_full)" || return +# fi +# ;; +# *CYGWIN*) +# wmic path Win32_Battery 2>&1 | grep -q 'No Instance' && return +# discharging=$(wmic path Win32_Battery Get BatteryStatus 2>/dev/null | grep -q 1 && echo "true" || echo "false") +# percentage=$(wmic path Win32_Battery Get EstimatedChargeRemaining /format:list 2>/dev/null | grep '[^[:blank:]]' | cut -d= -f2) +# charge="${percentage} / 100" +# ;; +# *OpenBSD*) +# discharging=$(sysctl -n hw.sensors.acpibat0.raw0 | grep -q 1 && echo "true" || echo "false") +# if sysctl -n hw.sensors.acpibat0 | grep -q amphour; then +# charge="$(sysctl -n hw.sensors.acpibat0.amphour3 | cut -d' ' -f1) / $(sysctl -n hw.sensors.acpibat0.amphour0 | cut -d' ' -f1)" +# else +# charge="$(sysctl -n hw.sensors.acpibat0.watthour3 | cut -d' ' -f1) / $(sysctl -n hw.sensors.acpibat0.watthour0 | cut -d' ' -f1)" +# fi +# ;; +# *) +# return +# esac # -# battery_style=$1 -# battery_symbol=$2 -# battery_symbol_count=$3 -# battery_palette=$4 -# battery_status=$5 -# if [ x"$battery_symbol_count" = x"auto" ]; then +# 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_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_vbar_palette=$5 +# battery_status_charging=$6 +# battery_status_discharging=$7 +# +# if [ x"$battery_bar_length" = x"auto" ]; then # columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80) -# if [ $columns -ge 80 ]; then -# battery_symbol_count=10 +# if [ "$columns" -ge 80 ]; then +# battery_bar_length=10 # else -# battery_symbol_count=5 -# fi -# fi -# battery_symbol_heart_full=♥ -# battery_symbol_heart_empty=♥ -# battery_symbol_block_full=◼ -# battery_symbol_block_empty=◻ -# eval battery_symbol_full='$battery_symbol_'"$battery_symbol"'_full' -# eval battery_symbol_empty='$battery_symbol_'"$battery_symbol"'_empty' -# -# if [ x"$battery_status" = x"1" ] || [ x"$battery_status" = x"true" ] || [ x"$battery_status" = x"enabled" ] ; then -# if [ x"$discharging" = x"true" ]; then -# echo "$uname_s" | grep -q -v "CYGWIN" && printf "%s " 🔋 -# else -# printf "%s " ⚡ +# battery_bar_length=5 # fi # fi # -# if [ x"$battery_style" = x"percentage" ] ; then -# printf %.0f%% $(awk "BEGIN{print $charge * 100}") -# return +# if [ x"$discharging" = x"true" ]; then +# battery_status="$battery_status_discharging" +# else +# battery_status="$battery_status_charging" # fi # -# if echo $battery_palette | grep -q -E '^heat|gradient(,[a-z0-9]{7,9})?$'; then -# palette_style=$(echo $battery_palette | cut -d, -f1) -# battery_bg=$(echo $battery_palette | cut -s -d, -f2) -# battery_bg=${battery_bg:-colour16} -# gradient="196 202 208 214 220 226 190 154 118 82 46" -# heat="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" -# eval palette=$(echo \$$palette_style) -# count=$(echo $(echo $palette | wc -w)) +# 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; } +# palette_style=$1 +# battery_bg=${2:-none} +# [ x"$palette_style" = x"gradient" ] && \ +# palette="196 202 208 214 220 226 190 154 118 82 46" +# [ x"$palette_style" = x"heat" ] && \ +# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" # +# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }') # eval set -- "$palette" -# palette=$(eval echo $(eval echo $(printf "\\$\{\$(expr %s \* $count / $battery_symbol_count)\} " $(seq 1 $battery_symbol_count)))) # -# full=$(printf %.0f $(awk "BEGIN{print $charge * $battery_symbol_count}")) -# printf '#[bg=%s]' $battery_bg -# [ $full -gt 0 ] && \ -# printf "#[fg=colour%s]$battery_symbol_full" $(echo $palette | cut -d' ' -f1-$full) -# empty=$(($battery_symbol_count - $full)) -# if [ x"$battery_symbol" = x"heart" ]; then -# [ $empty -gt 0 ] && \ -# printf '#[fg=%s]' $battery_bg && \ -# printf "%0.s$battery_symbol_empty" $(seq 1 $empty) -# else -# [ $empty -gt 0 ] && \ -# printf "#[fg=colour%s]$battery_symbol_empty" $(echo $palette | cut -d' ' -f$((full+1))-$(($full + $empty))) +# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }") +# battery_bar="#[bg=$battery_bg]" +# # shellcheck disable=SC2046 +# [ "$full" -gt 0 ] && \ +# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))" +# # shellcheck disable=SC2046 +# empty=$((battery_bar_length - full)) +# # shellcheck disable=SC2046 +# [ "$empty" -gt 0 ] && \ +# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))" +# eval battery_bar="$battery_bar#[fg=colour\${$((full == 0 ? 1 : full))}]" +# elif echo "$battery_bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then +# # shellcheck disable=SC2086 +# { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; } +# battery_full_fg=$1 +# battery_empty_fg=$2 +# battery_bg=$3 +# +# full=$(awk "BEGIN { print \"%d\" ($charge) * $battery_bar_length }") +# [ x"$battery_bg" != x"none" ] && \ +# battery_bar="#[bg=$battery_bg]" +# [ "$full" -gt 0 ] && \ +# battery_bar="$battery_bar#[fg=$battery_full_fg]$(printf "%0.s$battery_bar_symbol_full" "$(seq 1 "$full")")" +# empty=$((battery_bar_length - full)) +# [ "$empty" -gt 0 ] && \ +# battery_bar="$battery_bar#[fg=$battery_empty_fg]$(printf "%0.s$battery_bar_symbol_empty" "$(seq 1 "$empty")")" && \ +# battery_bar="$battery_bar#[fg=$battery_empty_fg]" +# fi +# +# if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then +# # shellcheck disable=SC2086 +# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; } +# palette_style=$1 +# battery_vbar_bg=${2:-none} +# [ x"$palette_style" = x"gradient" ] && \ +# palette="196 202 208 214 220 226 190 154 118 82 46" +# [ x"$palette_style" = x"heat" ] && \ +# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" +# +# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }') +# eval set -- "$palette" +# +# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }") +# eval battery_vbar_fg="colour\${$((full == 0 ? 1 : full))}" +# elif echo "$battery_vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then +# # shellcheck disable=SC2086 +# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; } +# +# # shellcheck disable=SC2046 +# eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }") +# fi +# +# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █" +# # shellcheck disable=SC2046 +# eval $(awk "BEGIN { printf \"battery_vbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }") +# battery_vbar="#[fg=${battery_vbar_fg?}]#[bg=${battery_vbar_bg?}]${battery_vbar_symbol?}" +# +# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")" +# +# tmux set -g '@battery_status' "$battery_status" \;\ +# set -g '@battery_bar' "$battery_bar" \;\ +# set -g '@battery_vbar' "$battery_vbar" \;\ +# set -g '@battery_percentage' "$battery_percentage" +# } +# +# _username() { +# tty=${1:-$(tmux display -p '#{pane_tty}')} +# ssh_only=$2 +# # shellcheck disable=SC2039 +# if [ x"$OSTYPE" = x"cygwin" ]; then +# pid=$(ps -a | awk -v tty="${tty##/dev/}" '$5 == tty && /ssh/ && !/autossh/ && !/-W/ { print $1 }') +# [ -n "$pid" ] && ssh_parameters=$(tr '\0' ' ' < "/proc/$pid/cmdline" | sed 's/^ssh //') +# else +# ssh_parameters=$(ps -t "$tty" -o command= | awk '/ssh/ && !/autossh/ && !/-W/ { $1=""; print $0; exit }') +# fi +# if [ -n "$ssh_parameters" ]; then +# # shellcheck disable=SC2086 +# username=$(ssh -G $ssh_parameters 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_parameters 2>&1 | awk '/^%username% / { print $2; exit }') +# else +# if ! _is_enabled "$ssh_only"; then +# # shellcheck disable=SC2039 +# if [ x"$OSTYPE" = x"cygwin" ]; then +# username=$(whoami) +# else +# username=$(ps -t "$tty" -o user= -o pid= -o ppid= -o command= | awk ' +# !/ssh/ { user[$2] = $1; ppid[$3] = 1 } +# END { +# for (i in user) +# if (!(i in ppid)) +# { +# print user[i] +# exit +# } +# } +# ') +# fi # fi -# elif echo $battery_palette | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then -# battery_full_fg=$(echo $battery_palette | cut -d, -f1) -# battery_empty_fg=$(echo $battery_palette | cut -d, -f2) -# battery_bg=$(echo $battery_palette | cut -d, -f3) +# fi # -# full=$(printf %.0f $(awk "BEGIN{print $charge * $battery_symbol_count}")) -# [ $full -gt 0 ] && \ -# printf '#[fg=%s,bg=%s]' $battery_full_fg $battery_bg && \ -# printf "%0.s$battery_symbol_full" $(seq 1 $full) -# empty=$(($battery_symbol_count - $full)) -# [ $empty -gt 0 ] && \ -# printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_bg && \ -# printf "%0.s$battery_symbol_empty" $(seq 1 $empty) +# echo "$username" +# } +# +# _hostname() { +# tty=${1:-$(tmux display -p '#{pane_tty}')} +# ssh_only=$2 +# # shellcheck disable=SC2039 +# if [ x"$OSTYPE" = x"cygwin" ]; then +# pid=$(ps -a | awk -v tty="${tty##/dev/}" '$5 == tty && /ssh/ && !/autossh/ && !/-W/ { print $1 }') +# [ -n "$pid" ] && ssh_parameters=$(tr '\0' ' ' < "/proc/$pid/cmdline" | sed 's/^ssh //') +# else +# ssh_parameters=$(ps -t "$tty" -o command= | awk '/ssh/ && !/autossh/ && !/-W/ { $1=""; print $0; exit }') +# fi +# if [ -n "$ssh_parameters" ]; then +# # shellcheck disable=SC2086 +# hostname=$(ssh -G $ssh_parameters 2>/dev/null | awk 'NR > 2 { exit } ; /^hostname / { print $2 }') +# # shellcheck disable=SC2086 +# [ -z "$hostname" ] && hostname=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%hostname%% %h >&2'" $ssh_parameters 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] \ +# }') +# else +# if ! _is_enabled "$ssh_only"; then +# hostname=$(command hostname -s) +# fi +# fi +# +# echo "$hostname" +# } +# +# _root() { +# username=$(_username "$tty" false "$@") +# if [ x"$username" = x"root" ]; then +# tmux show -gqv '@root' # fi # } # -# apply_configurable_bindings() { -# tmux_conf_new_windows_retain_current_path=${tmux_conf_new_windows_retain_current_path:-false} -# if [ x"$tmux_conf_new_windows_retain_current_path" = x"true" ] || [ x"$tmux_conf_new_windows_retain_current_path" = x"1" ] ; then +# _uptime() { +# case $(uname -s) in +# *Darwin*) +# boot=$(sysctl -q -n kern.boottime | awk -F'[ ,:]+' '{ print $4 }') +# now=$(date +%s) +# ;; +# *Linux*|*CYGWIN*) +# now=$(cut -d' ' -f1 < /proc/uptime) +# ;; +# *OpenBSD*) +# boot=$(sysctl -n kern.boottime) +# now=$(date +%s) +# esac +# # shellcheck disable=SC1004 +# awk -v boot="$boot" -v now="$now" ' +# BEGIN { +# uptime = now - boot +# d = int(uptime / 86400) +# h = int(uptime / 3600) % 24 +# m = int(uptime / 60) % 60 +# s = int(uptime) % 60 +# +# system("tmux set -g @uptime_d " d + 0 " \\; " \ +# "set -g @uptime_h " h + 0 " \\; " \ +# "set -g @uptime_m " m + 0 " \\; " \ +# "set -g @uptime_s " s + 0) +# }' +# } +# +# _split_window() { +# tty=${1:-$(tmux display -p '#{pane_tty}')} +# shift +# # shellcheck disable=SC2039 +# if [ x"$OSTYPE" = x"cygwin" ]; then +# pid=$(ps -a | sort -d | awk -v tty="${tty##/dev/}" '$5 == tty && /ssh/ && !/-W/ { print $1; exit 0 }') +# [ -n "$pid" ] && ssh=$(tr '\0' ' ' < "/proc/$pid/cmdline") +# else +# ssh=$(ps -t "$tty" -o command= | sort -d | awk '/ssh/ && !/-W/ { print $0; exit 0 }') +# fi +# if [ -n "$ssh" ]; then +# # shellcheck disable=SC2046 +# tmux split-window "$@" $(echo "$ssh" | sed -e "s/;/\\\\;/g") +# else +# tmux split-window "$@" +# fi +# } +# +# _apply_overrides() { +# tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-false} +# if _is_enabled "$tmux_conf_theme_24b_colour"; then +# case "$TERM" in +# screen-*|tmux-*) +# ;; +# *) +# tmux set-option -ga terminal-overrides ",$TERM:Tc" +# ;; +# esac +# fi +# } +# +# _apply_bindings() { +# 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 # tmux bind c new-window -c '#{pane_current_path}' # else # tmux bind c new-window # fi # -# tmux_conf_new_panes_retain_current_path=${tmux_conf_new_panes_retain_current_path:-true} -# if [ x"$tmux_conf_new_panes_retain_current_path" = x"true" ] || [ x"$tmux_conf_new_panes_retain_current_path" = x"1" ] ; then -# tmux bind '"' split-window -v -c "#{pane_current_path}" \;\ -# bind % split-window -h -c "#{pane_current_path}" \;\ -# bind - split-window -v -c "#{pane_current_path}" \;\ -# bind _ split-window -h -c "#{pane_current_path}" +# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true} +# 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 +# tmux bind '"' run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -v -c '#{pane_current_path}'" \;\ +# bind % run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -h -c '#{pane_current_path}'" \;\ +# bind - run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -v -c '#{pane_current_path}'" \;\ +# bind _ run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -h -c '#{pane_current_path}'" +# else +# tmux bind '"' run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -v" \;\ +# bind % run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -h" \;\ +# bind - run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -v" \;\ +# bind _ run "cut -c3- ~/.tmux.conf | sh -s _split_window #{pane_tty} -h" +# fi # else -# tmux bind '"' split-window -v \;\ -# bind % split-window -h \;\ -# bind - split-window -v \;\ -# bind _ split-window -h +# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then +# tmux bind '"' split-window -v -c '#{pane_current_path}' \;\ +# bind % split-window -h -c '#{pane_current_path}' \;\ +# bind - split-window -v -c '#{pane_current_path}' \;\ +# bind _ split-window -h -c '#{pane_current_path}' +# else +# tmux bind '"' split-window -v \;\ +# bind % split-window -h \;\ +# bind - split-window -v \;\ +# bind _ split-window -h +# fi # fi # # tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false} -# if [ x"$tmux_conf_new_session_prompt" = x"true" ] || [ x"$tmux_conf_new_session_prompt" = x"1" ] ; then -# tmux bind C-c command-prompt -p new-session 'new-session -s %%' +# if _is_enabled "$tmux_conf_new_session_prompt"; then +# tmux bind C-c command-prompt -p new-session 'new-session -s "%%"' # else # tmux bind C-c new-session # fi +# +# if tmux -q -L swap-pane-test -f /dev/null new-session -d \; new-window \; new-window \; swap-pane -t :1 \; kill-session; then +# tmux bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane' +# else +# tmux bind + display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e' +# fi # } # -# apply_configuration() { -# apply_theme -# apply_configurable_bindings +# _apply_theme() { # -# if tmux -q -L swap-pane-test -f /dev/null new-session -d \; new-window \; new-window \; swap-pane -t :1 \; kill-session; then -# tmux bind + run 'cut -c3- ~/.tmux.conf | sh -s maximize_pane' -# else -# tmux bind + display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e' -# fi +# # -- panes ------------------------------------------------------------- # -# for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $name; done; +# 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 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 +# 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_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 +# fat) +# tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-$tmux_conf_theme_pane_border_fg} +# 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'} +# ;; +# 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=${tmux_conf_theme_left_separator_main-''} +# tmux_conf_theme_left_separator_sub=${tmux_conf_theme_left_separator_sub-'|'} +# tmux_conf_theme_right_separator_main=${tmux_conf_theme_right_separator_main-''} +# tmux_conf_theme_right_separator_sub=${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 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_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'} +# 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=default,bg=default,default] $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 +# tmux_conf_theme_window_status_current_format="#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_window_status_current_bg]$tmux_conf_theme_left_separator_main#[fg=default,bg=default,default] $tmux_conf_theme_window_status_current_format #[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_status_bg,none]$tmux_conf_theme_left_separator_main" +# fi +# +# tmux_conf_theme_window_status_format=$(echo "$tmux_conf_theme_window_status_format" | sed 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled_digit #I)%g') +# tmux_conf_theme_window_status_current_format=$(echo "$tmux_conf_theme_window_status_current_format" | sed 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled_digit #I)%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 "$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 "$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 +# +# 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_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'} +# +# # -- 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=$(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") +# +# 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") +# +# if [ -n "$tmux_conf_theme_status_left" ]; then +# 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) +# { +# l = split(s, a, ",") +# for (i = 1; i <= l; ++i) +# { +# o = split(a[i], _, "(") - 1 +# c = split(a[i], _, ")") - 1 +# open += o - c +# o_ = split(a[i], _, "{") - 1 +# c_ = split(a[i], _, "}") - 1 +# open_ += o_ - c_ +# o__ = split(a[i], _, "[") - 1 +# c__ = split(a[i], _, "]") - 1 +# open__ += o__ - c__ +# +# if (i == l) +# r = sprintf("%s%s", r, a[i]) +# else if (open || open_ || open__) +# r = sprintf("%s%s,", r, a[i]) +# else +# r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep) +# } +# +# gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r) +# return r +# } +# BEGIN { +# FS = "|" +# l1 = split(fg_, fg, ",") +# l2 = split(bg_, bg, ",") +# l3 = split(attr_, attr, ",") +# l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3) +# } +# { +# for (i = j = 1; i <= NF; ++i) +# { +# if (open || open_ || open__) +# printf "|%s", subsplit($i) +# else +# { +# if (i > 1) +# printf "#[fg=%s,bg=%s,none]%s#[fg=%s,bg=%s,%s]%s", bg[j_], bg[j], mainsep, fg[j], bg[j], attr[j], subsplit($i) +# else +# printf "#[fg=%s,bg=%s,%s]%s", fg[j], bg[j], attr[j], subsplit($i) +# } +# +# if (!open && !open_ && !open__) +# { +# j_ = j +# j = j % l + 1 +# } +# } +# printf "#[fg=%s,bg=%s,none]%s", bg[j_], "default", mainsep +# }' << EOF +# $tmux_conf_theme_status_left +# EOF +# ) +# +# # are we running a tmux in between v1.9 and v2.0? +# if [ x"$(tmux -q -L tmux_theme_status_left_test -f /dev/null new-session -d \; show -g -v status-left \; kill-session)" = x"[#S] " ]; then +# case "$status_left" in +# *\ ) +# ;; +# *) +# status_left="$status_left " +# ;; +# esac +# fi +# fi +# +# # -- 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=$(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") +# +# 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") +# +# if [ -n "$tmux_conf_theme_status_right" ]; then +# 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) +# { +# l = split(s, a, ",") +# for (i = 1; i <= l; ++i) +# { +# o = split(a[i], _, "(") - 1 +# c = split(a[i], _, ")") - 1 +# open += o - c +# o_ = split(a[i], _, "{") - 1 +# c_ = split(a[i], _, "}") - 1 +# open_ += o_ - c_ +# o__ = split(a[i], _, "[") - 1 +# c__ = split(a[i], _, "]") - 1 +# open__ += o__ - c__ +# +# if (i == l) +# r = sprintf("%s%s", r, a[i]) +# else if (open || open_ || open__) +# r = sprintf("%s%s,", r, a[i]) +# else +# r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep) +# } +# +# gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r) +# return r +# } +# BEGIN { +# FS = "|" +# l1 = split(fg_, fg, ",") +# l2 = split(bg_, bg, ",") +# l3 = split(attr_, attr, ",") +# l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3) +# } +# { +# for (i = j = 1; i <= NF; ++i) +# { +# if (open_ || open || open__) +# printf "|%s", subsplit($i) +# else +# printf "#[fg=%s,bg=%s,none]%s#[fg=%s,bg=%s,%s]%s", bg[j], (i == 1) ? "default" : bg[j_], mainsep, fg[j], bg[j], attr[j], subsplit($i) +# +# if (!open && !open_ && !open__) +# { +# j_ = j +# j = j % l + 1 +# } +# } +# }' << EOF +# $tmux_conf_theme_status_right +# EOF +# ) +# fi +# +# # -- 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'} +# tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-'gradient'} +# 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+26A1 +# tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-'🔋'} # U+1F50B +# +# case "$status_left $status_right" in +# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) +# status_left=$(echo "$status_left" | sed -E \ +# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/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_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' "$tmux_conf_battery_bar_symbol_full" \;\ +# set -g '@battery_bar_symbol_empty' "$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_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\ +# set -g '@battery_status_charging' "$tmux_conf_battery_status_charging" \;\ +# set -g '@battery_status_discharging' "$tmux_conf_battery_status_discharging" +# status_right="#(cut -c3- ~/.tmux.conf | sh -s _battery)$status_right" +# ;; +# esac +# +# case "$status_left $status_right" in +# *'#{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%#{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') +# 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%#{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') +# ;; +# esac +# +# case "$status_left $status_right" in +# *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*) +# status_left=$(echo "$status_left" | sed -E \ +# -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ +# -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=$(echo "$status_right" | sed -E \ +# -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ +# -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" +# ;; +# esac +# +# status_left=$(echo "$status_left" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled_digit #S)%g') +# status_right=$(echo "$status_right" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled_digit #S)%g') +# +# tmux set -g status-left-length 1000 \; set -g status-left "$status_left" \;\ +# set -g status-right-length 1000 \; set -g status-right "$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" # } # -# urlview() { -# tmux capture-pane -J -S - -E - -b urlview-$1 -t $1 +# _apply_configuration() { +# _apply_overrides +# _apply_bindings +# _apply_theme +# for name in $(printenv | grep -Eo '^tmux_conf_[^=]+'); do tmux setenv -gu "$name"; done; +# } +# +# _urlview() { +# tmux capture-pane -J -S - -E - -b "urlview-$1" -t "$1" # tmux split-window "tmux show-buffer -b urlview-$1 | urlview || true; tmux delete-buffer -b urlview-$1" # } # -# fpp() { -# tmux capture-pane -J -S - -E - -b fpp-$1 -t $1 +# _fpp() { +# tmux capture-pane -J -S - -E - -b "fpp-$1" -t "$1" # tmux split-window "tmux show-buffer -b fpp-$1 | fpp || true; tmux delete-buffer -b fpp-$1" # } # -# $@ +# "$@" diff --git a/.tmux.conf.local b/.tmux.conf.local index 4bac702..10c6d5e 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -1,117 +1,233 @@ +# https://github.com/gpakosz/.tmux # (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz) -# use the powerline patched font variant of the theme, possible values are: -# - default -# - powerline -tmux_conf_theme=default -#tmux_conf_theme=powerline -# display an indicator in the status line when the prefix key has been pressed, -# possible values are: -# - enabled -# - disabled -tmux_conf_theme_prefix=disabled -#tmux_conf_theme_prefix=enabled - -# display the battery information in the status line, possible values are: -# - enabled -# - disabled -tmux_conf_theme_battery=enabled -#tmux_conf_theme_battery=disabled - -# style to use for the battery status, possible values are: -# - bar -# - percentage -tmux_conf_battery_style=bar -#tmux_conf_battery_style=percentage - -# symbols to use for battery status, possible values are: -# - block -# - heart -tmux_conf_battery_symbol=block -#tmux_conf_battery_symbol=heart - -# number of symbols to use for battery status -tmux_conf_battery_symbol_count=auto -#tmux_conf_battery_symbol_count=5 - -# palette used for the battery status, possible values are: -# - 'colour_full_fg,colour_empty_fg,colour_bg' -# - heat -# - gradient -tmux_conf_battery_palette='#d70000,#e4e4e4,#000000' -#tmux_conf_battery_palette=colour160,colour254,colour16 -#tmux_conf_battery_palette=heat -#tmux_conf_battery_palette=gradient - -# display the battery status: charging (U+26A1) / discharging (U+1F50B) -tmux_conf_battery_status=enabled -#tmux_conf_battery_status=disabled - -# or alternatively use an external tool, e.g. https://github.com/Goles/Battery -#tmux_conf_battery='#(battery -t) ' - -# display the time in the status line, possible values are: -# - enabled -# - disabled -tmux_conf_theme_time=enabled -#tmux_conf_theme_time=disabled - -# display the date in the status line, possible values are: -# - enabled -# - disabled -tmux_conf_theme_date=enabled -#tmux_conf_theme_date=disabled - -# display the username in the status line, possible values are: -# - enabled -# - disabled -# - ssh -tmux_conf_theme_username=enabled -#tmux_conf_theme_username=disabled -#tmux_conf_theme_username=ssh - -# display the hostname in the status line, possible values are: -# - enabled -# - disabled -# - ssh -tmux_conf_theme_hostname=enabled -#tmux_conf_theme_hostname=disabled -#tmux_conf_theme_hostname=ssh - -# highlight focused pane, possible values are: -# - enabled -# - disabled -tmux_conf_theme_highlight_focused_pane=disabled -#tmux_conf_theme_highlight_focused_pane=enabled - -# should new windows retain current path, possible values are: -# - true -# - false -tmux_conf_new_windows_retain_current_path=false -#tmux_conf_new_windows_retain_current_path=true - -# should new panes retain current path, possible values are: -# - true -# - false -tmux_conf_new_panes_retain_current_path=true -#tmux_conf_new_panes_retain_current_path=false - -# prompt for session name when creating a new session, possible values are: -# - true -# - false -tmux_conf_new_session_prompt=false -#tmux_conf_new_session_prompt=true +# -- navigation ---------------------------------------------------------------- # if you're running tmux within iTerm2 # - and tmux is 1.9 or 1.9a # - and iTerm2 is configured to let option key act as +Esc # - and iTerm2 is configured to send [1;9A -> [1;9D for option + arrow keys # then uncomment the following line to make Meta + arrow keys mapping work -#set -g terminal-overrides "*:kUP3=\e[1;9A,*:kDN3=\e[1;9B,*:kRIT3=\e[1;9C,*:kLFT3=\e[1;9D" +#set -ga terminal-overrides "*:kUP3=\e[1;9A,*:kDN3=\e[1;9B,*:kRIT3=\e[1;9C,*:kLFT3=\e[1;9D" + + +# -- windows & pane creation --------------------------------------------------- + +# new window retains current path, possible values are: +# - true +# - false (default) +tmux_conf_new_window_retain_current_path=false + +# new pane retains current path, possible values are: +# - true (default) +# - false +tmux_conf_new_pane_retain_current_path=true + +# new pane tries to reconnect ssh sessions (experimental), possible values are: +# - true +# - false (default) +tmux_conf_new_pane_reconnect_ssh=false + +# prompt for session name when creating a new session, possible values are: +# - true +# - false (default) +tmux_conf_new_session_prompt=false + + +# -- display ------------------------------------------------------------------- + +# RGB 24-bit colour support (since tmux 2.2), possible values are: +# - true +# - false (default) +tmux_conf_theme_24b_colour=false + +# window style +tmux_conf_theme_window_fg='default' +tmux_conf_theme_window_bg='default' + +# highlight focused pane (tmux 2.1+), possible values are: +# - true +# - false (default) +tmux_conf_theme_highlight_focused_pane=false + +# focused pane colours: +tmux_conf_theme_focused_pane_fg='default' +tmux_conf_theme_focused_pane_bg='#0087d7' # light blue + +# pane border style, possible values are: +# - thin (default) +# - fat +tmux_conf_theme_pane_border_style=thin + +# pane borders colours: +tmux_conf_theme_pane_border='#444444' # gray +tmux_conf_theme_pane_active_border='#00afff' # light blue + +# pane indicator colours +tmux_conf_theme_pane_indicator='#00afff' # light blue +tmux_conf_theme_pane_active_indicator='#00afff' # light blue + +# status line style +tmux_conf_theme_message_fg='#000000' # black +tmux_conf_theme_message_bg='#ffff00' # yellow +tmux_conf_theme_message_attr='bold' + +# status line command style ( : Escape) +tmux_conf_theme_message_command_fg='#ffff00' # yellow +tmux_conf_theme_message_command_bg='#000000' # black +tmux_conf_theme_message_command_attr='bold' + +# window modes style +tmux_conf_theme_mode_fg='#000000' # black +tmux_conf_theme_mode_bg='#ffff00' # yellow +tmux_conf_theme_mode_attr='bold' + +# status line style +tmux_conf_theme_status_fg='#8a8a8a' # light gray +tmux_conf_theme_status_bg='#080808' # dark gray +tmux_conf_theme_status_attr='none' + +# window status style +# - built-in variables are: +# - #{circled_window_index} +tmux_conf_theme_window_status_fg='#8a8a8a' # light gray +tmux_conf_theme_window_status_bg='#080808' # dark gray +tmux_conf_theme_window_status_attr='none' +tmux_conf_theme_window_status_format='#I #W' +#tmux_conf_theme_window_status_format='#{circled_window_index} #W' +#tmux_conf_theme_window_status_format='#I #W#{?window_bell_flag,🔔,}#{?window_zoomed_flag,🔍,}' + +# window current status style +# - built-in variables are: +# - #{circled_window_index} +tmux_conf_theme_window_status_current_fg='#000000' # black +tmux_conf_theme_window_status_current_bg='#00afff' # light blue +tmux_conf_theme_window_status_current_attr='bold' +tmux_conf_theme_window_status_current_format='#I #W' +#tmux_conf_theme_window_status_current_format='#{circled_window_index} #W' +#tmux_conf_theme_window_status_current_format='#I #W#{?window_zoomed_flag,🔍,}' + +# window activity status style +tmux_conf_theme_window_status_activity_fg='default' +tmux_conf_theme_window_status_activity_bg='default' +tmux_conf_theme_window_status_activity_attr='underscore' + +# window bell status style +tmux_conf_theme_window_status_bell_fg='#ffff00' # yellow +tmux_conf_theme_window_status_bell_bg='default' +tmux_conf_theme_window_status_bell_attr='blink,bold' + +# window last status style +tmux_conf_theme_window_status_last_fg='#00afff' # light blue +tmux_conf_theme_window_status_last_bg='default' +tmux_conf_theme_window_status_last_attr='none' + +# status left/right sections separators +tmux_conf_theme_left_separator_main='' +tmux_conf_theme_left_separator_sub='|' +tmux_conf_theme_right_separator_main='' +tmux_conf_theme_right_separator_sub='|' +#tmux_conf_theme_left_separator_main='' # /!\ you don't need to install powerline +#tmux_conf_theme_left_separator_sub='' # you only need fonts patched with +#tmux_conf_theme_right_separator_main='' # powerline symbols or the standalone +#tmux_conf_theme_right_separator_sub='' # PowerlineSymbols.otf font + +# status left/right content: +# - separate main sections with '|' +# - separate subsections with ',' +# - built-in variables are: +# - #{battery_bar} +# - #{battery_percentage} +# - #{battery_status} +# - #{battery_vbar} +# - #{circled_session_name} +# - #{hostname} +# - #{hostname_ssh} +# - #{pairing} +# - #{prefix} +# - #{root} +# - #{uptime_d} +# - #{uptime_h} +# - #{uptime_m} +# - #{uptime_s} +# - #{username} +# - #{username_ssh} +tmux_conf_theme_status_left=' ❐ #S | ↑#{?uptime_d, #{uptime_d}d,}#{?uptime_h, #{uptime_h}h,}#{?uptime_m, #{uptime_m}m,} ' +tmux_conf_theme_status_right='#{prefix}#{pairing}#{?battery_status, #{battery_status},}#{?battery_bar, #{battery_bar},}#{?battery_percentage, #{battery_percentage},} , %R , %d %b | #{username}#{root} | #{hostname} ' + +# status left style +tmux_conf_theme_status_left_fg='#000000,#e4e4e4,#e4e4e4' # black, white , white +tmux_conf_theme_status_left_bg='#ffff00,#ff00af,#00afff' # yellow, pink, white blue +tmux_conf_theme_status_left_attr='bold,none,none' + +# status right style +tmux_conf_theme_status_right_fg='#8a8a8a,#e4e4e4,#000000' # light gray, white, black +tmux_conf_theme_status_right_bg='#080808,#d70000,#e4e4e4' # dark gray, red, white +tmux_conf_theme_status_right_attr='none,none,bold' + +# pairing indicator +tmux_conf_theme_pairing='👓' # U+1F453 +tmux_conf_theme_pairing_fg='none' +tmux_conf_theme_pairing_bg='none' +tmux_conf_theme_pairing_attr='none' + +# prefix indicator +tmux_conf_theme_prefix='⌨' # U+2328 +tmux_conf_theme_prefix_fg='none' +tmux_conf_theme_prefix_bg='none' +tmux_conf_theme_prefix_attr='none' + +# root indicator +tmux_conf_theme_root='!' +tmux_conf_theme_root_fg='none' +tmux_conf_theme_root_bg='none' +tmux_conf_theme_root_attr='bold,blink' + +# battery bar symbols +tmux_conf_battery_bar_symbol_full='◼' +tmux_conf_battery_bar_symbol_empty='◻' +#tmux_conf_battery_bar_symbol_full='♥' +#tmux_conf_battery_bar_symbol_empty='·' + +# battery bar length (in number of symbols), possible values are: +# - auto +# - a number, e.g. 5 +tmux_conf_battery_bar_length='auto' + +# battery bar palette, possible values are: +# - gradient (default) +# - heat +# - 'colour_full_fg,colour_empty_fg,colour_bg' +tmux_conf_battery_bar_palette='gradient' +#tmux_conf_battery_bar_palette='#d70000,#e4e4e4,#000000' # red, white, black + +# battery vbar palette, possible values are: +# - gradient (default) +# - heat +# - 'colour_low,colour_half,colour_full' +tmux_conf_battery_vbar_palette='gradient' +#tmux_conf_battery_vbar_palette='#d70000,#ff5f00,#5fff00' # red, orange, green + +# symbols used to indicate whether battery is charging or discharging +tmux_conf_battery_status_charging='⚡' # U+26A1 +tmux_conf_battery_status_discharging='🔋' # U+1F50B + +# clock style +tmux_conf_theme_clock_colour='#00afff' # light blue +tmux_conf_theme_clock_style='24' # ------------------------------------------------------------------------------ -# this is the place to further customize tmux's configuration +# this is the place to override or undo settings +# increase history size #set -g history-limit 10000 + +# force Vi mode +# really you should export VISUAL or EDITOR environment variable, see manual +#set -g status-keys vi +#set -g mode-keys vi + +# move status line to top +#set -g status-position top diff --git a/README.md b/README.md index 6ec3478..851d38f 100644 --- a/README.md +++ b/README.md @@ -3,26 +3,51 @@ Self-contained, pretty and versatile `.tmux.conf` configuration file. -![Screenshot](https://cloud.githubusercontent.com/assets/553208/9889393/85e50e4e-5bfa-11e5-99d8-76572350803a.gif) +![Screenshot](https://cloud.githubusercontent.com/assets/553208/19740585/85596a5a-9bbf-11e6-8aa1-7c8d9829c008.gif) -The `master` branch targets tmux `HEAD`. You may want to use the `1.9`, `2.0` or -`2.1` branch. +Installation +------------ + +Requirements: + + - tmux **`2.1+`** running inside Linux, Mac, OpenBSD or Cygwin + - outside of tmux, `$TERM` must be set to `xterm-256color` + +To install, run the following from your terminal: + +``` +$ cd +$ git clone https://github.com/gpakosz/.tmux.git +$ ln -s .tmux/.tmux.conf +$ cp .tmux/.tmux.conf.local . +``` + +Then proceed to customize your `~/.tmux.conf.local` copy. + +If you're a Vim user, setting the `$EDITOR` environment variable to `vim` will +enable and further customize the vi-style key bindings (see tmux manual). Features -------- - `C-a` acts as secondary prefix, while keeping default `C-b` prefix - visual theme inspired by [Powerline][] - - [maximize any pane to a new window with ` +`](http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/) + - [maximize any pane to a new window with ` +`][maximize-pane] + - SSH aware username and hostname status line information - mouse mode toggle with ` m` - - automatic usage of `reattach-to-user-namespace` if available - - laptop battery status - - optional highlight of focused pane (tmux `2.1`+) + - automatic usage of [`reattach-to-user-namespace`][reattach-to-user-namespace] + if available + - laptop battery status line information + - uptime status line information + - optional highlight of focused pane (tmux `2.1+`) - configurable new windows and panes behavior (optionally retain current path) + - SSH aware split pane (reconnects to remote server, experimental) - [Facebook PathPicker][] integration if available - [Urlview][] integration if available [Powerline]: https://github.com/Lokaltog/powerline +[maximize-pane]: http://pempek.net/articles/2013/04/14/maximizing-tmux-pane-new-window/ +[reattach-to-user-namespace]: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard [Facebook PathPicker]: https://facebook.github.io/PathPicker/ [Urlview]: https://packages.debian.org/stable/misc/urlview @@ -61,8 +86,8 @@ Bindings for the `vi-choice` mode-table: - `l` expands the current tree node - `H` collapses all the tree nodes - `L` expands all the tree nodes -- `K` jumps to the start of list (tmux 2.0+) -- `L` jumps to the end of list (tmux 2.0+) +- `K` jumps to the start of list (tmux `2.0+`) +- `L` jumps to the end of list (tmux `2.0+`) - `Escape` cancels the current operation Bindings for the `vi-edit` mode-table: @@ -82,47 +107,33 @@ Bindings for the `vi-copy` mode-table: - `Escape` cancels the current operation The "maximize any pane to a new window with ` +`" feature is different -from stock `resize-pane -Z` as it allows you to further split a maximized pane. -Also, you can maximize a pane to a new window, then change window, then go back -and the pane is still in maximized state in its own window. You can then -minimize a pane by using ` +` either from the source window or the -maximized window. +from builtin `resize-pane -Z` as it allows you to further split a maximized +pane. It's also more flexible by allowing you to maximize a pane to a new +window, then change window, then go back and the pane is still in maximized +state in its own window. You can then minimize a pane by using ` +` +either from the source window or the maximized window. ![Maximize pane](https://cloud.githubusercontent.com/assets/553208/9890858/ee3c0ca6-5c02-11e5-890e-05d825a46c92.gif) Mouse mode allows you to set the active window, set the active pane, resize -panes and select switch to copy-mode to select text. +panes and automatically switches to copy-mode to select text. ![Mouse mode](https://cloud.githubusercontent.com/assets/553208/9890797/8dffe542-5c02-11e5-9c06-a25b452e6fcc.gif) -Installation ------------- - - $ cd - $ rm -rf .tmux - $ git clone https://github.com/gpakosz/.tmux.git - $ ln -s .tmux/.tmux.conf - $ cp .tmux/.tmux.conf.local . - -If you're a Vim user, setting the `$EDITOR` environment variable to `vim` will -enable and further customize the vi-style key bindings (see tmux manual). - Configuration ------------- While this configuration tries to bring sane default settings, you may want to customize it further to your needs. Instead of altering the `~/.tmux.conf` file and diverging from upstream, the proper way is to edit the `~/.tmux.conf.local` -file: +file. - echo "set -g history-limit 10000" >> ~/.tmux.conf.local - -You will also notice the default `.tmux.conf.local` file contains variables you -can change to alter different behaviors. Pressing ` e` will open +Please refer to the default `.tmux.conf.local` file to know more about variables +you can adjust to alter different behaviors. Pressing ` e` will open `~/.tmux.conf.local` with the editor defined by the `$EDITOR` environment variable (defaults to `vim` when empty). -### Enabling the Powerline like visual theme +### Enabling the Powerline look Powerline originated as a status-line plugin for Vim. Its popular eye-catching look is based on the use of special symbols: Powerline Symbols @@ -130,156 +141,68 @@ look is based on the use of special symbols: