diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bfd626 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugins/** diff --git a/.tmux.conf b/.tmux.conf index 33d6f26..856665a 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -9,7 +9,9 @@ # -- general ------------------------------------------------------------------- -set -g default-terminal "screen-256color" # colors! +set -g default-terminal "screen-256color" +if 'infocmp -x tmux-256color > /dev/null 2>&1' 'set -g default-terminal "tmux-256color"' + setw -g xterm-keys on set -s escape-time 10 # faster command sequences set -sg repeat-time 600 # increase repeat timeout @@ -46,7 +48,7 @@ set -g display-time 1000 # slightly longer status messages display time set -g status-interval 10 # redraw status line every 10 seconds # clear both screen and history -bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history +bind -n C-l send-keys C-l \; run 'sleep 0.2' \; clear-history # activity set -g monitor-activity on @@ -61,6 +63,9 @@ bind C-c new-session # find session bind C-f command-prompt -p find-session 'switch-client -t %%' +# session navigation +bind BTab switch-client -l # move to last session + # split current window horizontally bind - split-window -v # split current window vertically @@ -142,12 +147,12 @@ run -b 'tmux bind -T copy-mode-vi H send -X start-of-line 2> /dev/null || true' run -b 'tmux bind -t vi-copy L end-of-line 2> /dev/null || true' run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true' -# copy to macOS clipboard -if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"' -if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"' # copy to X11 clipboard if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"' if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"' +# copy to macOS clipboard +if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"' +if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"' # copy to Windows clipboard if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"' if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"' @@ -162,13 +167,12 @@ bind P choose-buffer # choose which buffer to paste from # -- user defined overrides ---------------------------------------------------- -if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local' +source -q ~/.tmux.conf.local # -- 8< ------------------------------------------------------------------------ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' -run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-time 3000 \; display "This configuration will soon require tmux >= 2.4" \; set -u display-time || true' # EOF @@ -190,7 +194,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # _uname_s=$(uname -s) # -# _tmux_version=$(tmux -V | tr -cd '[:digit:].' | cut -d' ' -f2 | awk -F '.' '{print $1 * 100 + $2}') +# _tmux_version=$(tmux -V | awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}') # # _is_enabled() { # [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"enabled" ] || [ x"$1" = x"1" ] @@ -278,8 +282,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # new="on" # fi # -# tmux set -g mouse $new \;\ -# display "mouse: $new" +# tmux set -g mouse $new # } # # _battery_info() { @@ -290,7 +293,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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]+%') +# percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%' || echo "0%") # charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }') # count=$((count + 1)) # done << EOF @@ -305,7 +308,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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 }') +# charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + (capacity > 100 ? 100 : capacity) / 100 }') # else # bat_energy_full="$batpath/energy_full" # bat_energy_now="$batpath/energy_now" @@ -495,51 +498,52 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # set -g '@battery_percentage' "$battery_percentage" # } # -# _tty_info() { -# tty="${1##/dev/}" +# _pane_info() { +# pane_pid="$1" +# pane_tty="${2##/dev/}" # case "$_uname_s" in # *CYGWIN*) -# ps -al | tail -n +2 | awk -v tty="$tty" ' -# ((/ssh/ && !/-W/) || !/ssh/) && $5 == tty { -# user[$1] = $6; parent[$1] = $2; child[$2] = $1 +# ps -al | tail -n +2 | awk -v pane_pid="$pane_pid" -v tty="$pane_tty" ' +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ && $5 == tty { +# user[$1] = $6; if (!child[$2]) child[$2] = $1 # } # END { -# for (i in parent) -# { -# j = i -# while (parent[j]) -# j = parent[j] +# pid = pane_pid +# while (child[pid]) +# pid = child[pid] # -# 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 -# } -# } +# file = "/proc/" pid "/cmdline"; getline command < file; close(file) +# gsub(/\0/, " ", command) +# "id -un " user[pid] | getline username +# print pid":"username":"command +# } +# ' +# ;; +# *Linux*) +# ps -t "$pane_tty" --sort=lstart -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk -v pane_pid="$pane_pid" ' +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ { +# user[$2] = $1; if (!child[$3]) child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4) +# } +# END { +# pid = pane_pid +# while (child[pid]) +# pid = child[pid] +# +# print pid":"user[pid]":"command[pid] # } # ' # ;; # *) -# 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) +# ps -t "$pane_tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk -v pane_pid="$pane_pid" ' +# ((/ssh/ && !/-W/) || !/ssh/) && !/tee/ { +# user[$2] = $1; if (!child[$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] +# pid = pane_pid +# while (child[pid]) +# pid = child[pid] # -# if (!(i in child) && j != 1) -# { -# print i":"user[i]":"command[i] -# exit -# } -# } +# print pid":"user[pid]":"command[pid] # } # ' # ;; @@ -549,7 +553,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # _ssh_or_mosh_args() { # case "$1" in # *ssh*) -# args=$(printf '%s' "$1" | perl -n -e 'print if s/(.*?)\bssh\b\s+(.*)/\2/') +# args=$(printf '%s' "$1" | perl -n -e 'print if s/.*?\bssh[\w]*\s*((?:\s+-\w+)*)(\s+\w+)(\s\w+)?/\1\2/') # ;; # *mosh-client*) # args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') @@ -560,11 +564,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _username() { -# tty=${1:-$(tmux display -p '#{pane_tty}')} -# ssh_only=$2 +# pane_pid=${1:-$(tmux display -p '#{pane_pid}')} +# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')} +# ssh_only=$3 # -# tty_info=$(_tty_info "$tty") -# command=${tty_info#*:} +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") +# command=${pane_info#*:} # command=${command#*:} # # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") @@ -572,10 +577,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # shellcheck disable=SC2086 # 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 }') +# [ -z "$username" ] && username=$(ssh $ssh_or_mosh_args -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" 2>&1 | awk '/^%username% / { print $2; exit }') +# [ -z "$username" ] && username=$(ssh $ssh_or_mosh_args -v -T -o ControlPath=none -o ProxyCommand=false -o IdentityFile='%%username%%/%r' 2>&1 | awk '/%username%/ { print substr($4,12); exit }') # else # if ! _is_enabled "$ssh_only"; then -# username=${tty_info#*:} +# username=${pane_info#*:} # username=${username%%:*} # fi # fi @@ -584,11 +590,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _hostname() { -# tty=${1:-$(tmux display -p '#{pane_tty}')} -# ssh_only=$2 +# pane_pid=${1:-$(tmux display -p '#{pane_pid}')} +# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')} +# ssh_only=$3 +# full=$4 +# h_or_H=$5 # -# tty_info=$(_tty_info "$tty") -# command=${tty_info#*:} +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") +# command=${pane_info#*:} # command=${command#*:} # # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command") @@ -598,17 +607,19 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # 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 }') # -# case "$hostname" in -# *[a-z-].*) -# hostname=${hostname%%.*} -# ;; -# 127.0.0.1) -# hostname="localhost" -# ;; -# esac +# if ! _is_enabled "$full"; then +# case "$hostname" in +# *[a-z-].*) +# hostname=${hostname%%.*} +# ;; +# 127.0.0.1) +# hostname="localhost" +# ;; +# esac +# fi # else # if ! _is_enabled "$ssh_only"; then -# hostname=$3 +# hostname="$h_or_H" # fi # fi # @@ -616,10 +627,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _root() { -# tty=${1:-$(tmux display -p '#{pane_tty}')} -# root=$2 +# pane_pid=${1:-$(tmux display -p '#{pane_pid}')} +# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')} +# root=$3 # -# username=$(_username "$tty" false) +# username=$(_username "$pane_id" "$pane_tty" false) # # [ x"$username" = x"root" ] && echo "$root" # } @@ -673,11 +685,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # } # # _split_window_ssh() { -# tty=${1:-$(tmux display -p '#{pane_tty}')} -# shift +# pane_pid=${1:-$(tmux display -p '#{pane_pid}')} +# pane_tty=${2:-$(tmux display -p '#{b:pane_tty}')} +# shift 2 # -# tty_info=$(_tty_info "$tty") -# command=${tty_info#*:} +# pane_info=$(_pane_info "$pane_pid" "$pane_tty") +# command=${pane_info#*:} # command=${command#*:} # # case "$command" in @@ -702,13 +715,13 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-false} # tmux_conf_24b_colour=${tmux_conf_24b_colour:-$tmux_conf_theme_24b_colour} # if _is_enabled "$tmux_conf_24b_colour"; then -# case "$TERM" in -# screen-*|tmux-*) -# ;; -# *) -# tmux set-option -ga terminal-overrides ",*256col*:Tc" -# ;; -# esac +# case "$TERM" in +# screen-*|tmux-*) +# ;; +# *) +# tmux set-option -ga terminal-overrides ",*256col*:Tc" +# ;; +# esac # fi # } # @@ -724,9 +737,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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+#\{b: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_pid} #{b: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/\brun-shell\b(\s+((?:\\\\\")?|\"?|'?)cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+((?:\\\\\")?|\"?|'?)#\{b: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" @@ -734,38 +747,38 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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/\bnew-window\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/ +# s/\bnew-window\b(?!\s+(?:-|}))/{$&}/g if /\bdisplay-menu\b/ # ; # s/\bnew-window\b/new-window -c '#\{pane_current_path\}'/g" \ # "$cfg" # fi # # perl -p -i -e " -# s/\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window_ssh #\{pane_tty\}\1'/g if /\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/"\ +# s/\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1'/g if /\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/"\ # "$cfg" # # 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 -# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #\{pane_tty\}\1'/g" "$cfg" +# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #\{pane_pid\} #\{b: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(?!\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(_ssh)?\s+#\{pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\2'/g if /\bdisplay-menu\b/ +# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{b:pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\2'/g if /\bdisplay-menu\b/ # ; -# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{pane_tty\} -c \"#\{pane_current_path\}\"\2'/g" \ +# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{b:pane_tty\} -c \"#\{pane_current_path\}\"\2'/g" \ # "$cfg" # fi # # tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false} # if _is_enabled "$tmux_conf_new_session_prompt"; then # perl -p -i \ -# -e "s/(? /dev/null 2>&1 && command='pbcopy' -# command -v reattach-to-user-namespace > /dev/null 2>&1 && command='reattach-to-user-namespace pbcopy' # command -v xsel > /dev/null 2>&1 && command='xsel -i -b' # ! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1 && command='xclip -i -selection clipboard > \/dev\/null 2>\&1' +# command -v pbcopy > /dev/null 2>&1 && command='pbcopy' +# command -v reattach-to-user-namespace > /dev/null 2>&1 && command='reattach-to-user-namespace pbcopy' # command -v clip.exe > /dev/null 2>&1 && command='clip\.exe' # [ -c /dev/clipboard ] && command='cat > \/dev\/clipboard' # # if [ -n "$command" ]; then # if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then -# perl -p -i -e "s/\bcopy-selection(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg" +# perl -p -i -e "s/(?!.*?$command)\bcopy-(?:selection|pipe)(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg" # else -# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2/copy-selection\1/g" "$cfg" +# if [ $_tmux_version -ge 320 ]; then +# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-pipe\1/g" "$cfg" +# else +# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-selection\1/g" "$cfg" +# fi # fi # fi # @@ -887,10 +904,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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' \ # -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 #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') +# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ +# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ +# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ +# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # # tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-$tmux_conf_theme_colour_3} # tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-$tmux_conf_theme_colour_1} @@ -914,35 +933,44 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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} # -# if [ x"$tmux_conf_theme_status_bg" = x"$tmux_conf_theme_window_status_bg" ]; then +# if [ x"$tmux_conf_theme_window_status_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_bg" = x"default" ]; then # spacer='' # spacer_current=' ' # else # spacer=' ' # spacer_current=' ' # fi -# if [ x"$tmux_conf_theme_status_bg" = x"$tmux_conf_theme_window_status_last_bg" ]; then +# if [ x"$tmux_conf_theme_window_status_last_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_last_bg" = x"default" ] ; then # spacer_last='' # else # spacer_last=' ' # fi -# if [ x"$tmux_conf_theme_status_bg" = x"$tmux_conf_theme_window_status_activity_bg" ]; then +# if [ x"$tmux_conf_theme_window_status_activity_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_activity_bg" = x"default" ] ; then # spacer_activity='' +# spacer_last_activity="$spacer_last" # else # spacer_activity=' ' +# spacer_last_activity=' ' # fi -# if [ x"$tmux_conf_theme_status_bg" = x"$tmux_conf_theme_window_status_bell_bg" ]; then +# if [ x"$tmux_conf_theme_window_status_bell_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_bell_bg" = x"default" ] ; then # spacer_bell='' +# spacer_last_bell="$spacer_last" +# spacer_activity_bell="$spacer_activity" +# spacer_last_activity_bell="$spacer_last_activity" # else # spacer_bell=' ' +# spacer_last_bell=' ' +# spacer_activity_bell=' ' +# spacer_last_activity_bell=' ' # fi +# spacer="#{?window_last_flag,#{?window_activity_flag,#{?window_bell_flag,$spacer_last_activity_bell,$spacer_last_activity},#{?window_bell_flag,$spacer_last_bell,$spacer_last}},#{?window_activity_flag,#{?window_bell_flag,$spacer_activity_bell,$spacer_activity},#{?window_bell_flag,$spacer_bell,$spacer}}}" # if [ x"$(tmux show -g -v status-justify)" = x"right" ]; then # if [ -z "$tmux_conf_theme_right_separator_main" ]; then # window_status_separator=' ' # else # window_status_separator='' # fi -# tmux_conf_theme_window_status_format="#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_status_bg,none]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_last_attr" | perl -n -e 'print "#[none]" if !/default/ ; s/([a-z]+),?/#{?window_last_flag,#[\1],}/g; print if !/default/')#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_activity_attr" | perl -n -e 'print "#[none]" if !/default/ ; s/([a-z]+),?/#{?window_activity_flag,#[\1],}/g; print if !/default/')#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_bell_attr" | perl -n -e 'print "#[none]" if !/default/ ; s/([a-z]+),?/#{?window_bell_flag,#[\1],}/g; print if !/default/')#{?window_bell_flag,$spacer_bell,#{?window_activity_flag,$spacer_activity,#{?window_last_flag,$spacer_last,$spacer}}}$tmux_conf_theme_window_status_format#{?window_bell_flag,$spacer_bell,#{?window_activity_flag,$spacer_activity,#{?window_last_flag,$spacer_last,$spacer}}}#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_bg]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#[none]$tmux_conf_theme_right_separator_main" +# tmux_conf_theme_window_status_format="#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_status_bg,none]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$spacer$(printf "$tmux_conf_theme_window_status_last_attr" | perl -n -e 'print "#{?window_last_flag,#[none],}" if !/default/ ; s/([a-z]+),?/#{?window_last_flag,#[\1],}/g; print if !/default/')$(printf "$tmux_conf_theme_window_status_activity_attr" | perl -n -e 'print "#{?window_activity_flag?,#[none],}" if !/default/ ; s/([a-z]+),?/#{?window_activity_flag,#[\1],}/g; print if !/default/')$(printf "$tmux_conf_theme_window_status_bell_attr" | perl -n -e 'print "#{?window_bell_flag,#[none],}" if !/default/ ; s/([a-z]+),?/#{?window_bell_flag,#[\1],}/g; print if !/default/')$tmux_conf_theme_window_status_format#[none]$spacer#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_bg]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#[none]$tmux_conf_theme_right_separator_main" # 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_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]$spacer_current$tmux_conf_theme_window_status_current_format$spacer_current#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_current_bg,none]$tmux_conf_theme_right_separator_main" # else # if [ -z "$tmux_conf_theme_left_separator_main" ]; then @@ -950,24 +978,28 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # else # window_status_separator='' # fi -# tmux_conf_theme_window_status_format="#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_bg,none]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$tmux_conf_theme_left_separator_main#[fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_last_attr" | perl -n -e 'print "#[none]" if !/default/ ; s/([a-z]+),?/#{?window_last_flag,#[\1],}/g; print if !/default/')#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_activity_attr" | perl -n -e 'print "#[none]" if !/default/ ; s/([a-z]+),?/#{?window_activity_flag,#[\1],}/g; print if !/default/')#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$(printf "$tmux_conf_theme_window_status_bell_attr" | perl -n -e 'print "#[none]" if /!default/ ; s/([a-z]+),?/#{?window_bell_flag,#[\1],}/g; print if !/default/')#{?window_bell_flag,$spacer_bell,#{?window_activity_flag,$spacer_activity,#{?window_last_flag,$spacer_last,$spacer}}}$tmux_conf_theme_window_status_format#{?window_bell_flag,$spacer_bell,#{?window_activity_flag,$spacer_activity,#{?window_last_flag,$spacer_last,$spacer}}}#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_status_bg]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#[none]$tmux_conf_theme_left_separator_main" +# tmux_conf_theme_window_status_format="#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_bg,none]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$tmux_conf_theme_left_separator_main#[fg=$tmux_conf_theme_window_status_fg,bg=$tmux_conf_theme_window_status_bg,$tmux_conf_theme_window_status_attr]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_fg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[bg=$&]/; print if !/default/"),}$spacer$(printf "$tmux_conf_theme_window_status_last_attr" | perl -n -e 'print "#{?window_last_flag,#[none],}" if !/default/ ; s/([a-z]+),?/#{?window_last_flag,#[\1],}/g; print if !/default/')$(printf "$tmux_conf_theme_window_status_activity_attr" | perl -n -e 'print "#{?window_activity_flag,#[none],}" if !/default/ ; s/([a-z]+),?/#{?window_activity_flag,#[\1],}/g; print if !/default/')$(printf "$tmux_conf_theme_window_status_bell_attr" | perl -n -e 'print "#{?window_bell_flag,#[none],}" if /!default/ ; s/([a-z]+),?/#{?window_bell_flag,#[\1],}/g; print if !/default/')$tmux_conf_theme_window_status_format#[none]$spacer#[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_status_bg]#{?window_last_flag,$(printf "$tmux_conf_theme_window_status_last_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_activity_flag,$(printf "$tmux_conf_theme_window_status_activity_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}#{?window_bell_flag,$(printf "$tmux_conf_theme_window_status_bell_bg" | perl -n -e "s/.+/#[fg=$&]/; print if !/default/"),}$tmux_conf_theme_left_separator_main" # tmux_conf_theme_window_status_current_format="#[fg=$tmux_conf_theme_status_bg,bg=$tmux_conf_theme_window_status_current_bg,none]$tmux_conf_theme_left_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]$spacer_current$tmux_conf_theme_window_status_current_format$spacer_current#[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_status_bg]$tmux_conf_theme_left_separator_main" # fi # # tmux_conf_theme_window_status_format=$(echo "$tmux_conf_theme_window_status_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 #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') +# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ +# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ +# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ +# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true 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 #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') +# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ +# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ +# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ +# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # # # -- indicators # @@ -981,6 +1013,11 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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_mouse=${tmux_conf_theme_mouse:-↗} # U+2197 +# tmux_conf_theme_mouse_fg=${tmux_conf_theme_mouse_fg:-none} +# tmux_conf_theme_mouse_bg=${tmux_conf_theme_mouse_bg:-none} +# tmux_conf_theme_mouse_attr=${tmux_conf_theme_mouse_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} @@ -1001,16 +1038,17 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # if [ -n "$tmux_conf_theme_status_left" ]; then # 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" \ -# -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 ,$(print "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/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 ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \ +# -e "s/#{mouse}/#[fg=$tmux_conf_theme_mouse_fg]#[bg=$tmux_conf_theme_mouse_bg]#[$tmux_conf_theme_mouse_attr]#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/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") +# -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_pid} #{b: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") +# -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_pid} #{b:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # status_left=$(printf '%s' "$status_left" | awk \ @@ -1080,7 +1118,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # # -- status-right style # -# 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=${tmux_conf_theme_status_right-' #{prefix}#{mouse}#{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:-$tmux_conf_theme_colour_12,$tmux_conf_theme_colour_13,$tmux_conf_theme_colour_14} # tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-$tmux_conf_theme_colour_15,$tmux_conf_theme_colour_16,$tmux_conf_theme_colour_17} # tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-none,none,bold} @@ -1089,15 +1127,16 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # 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" \ # -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 ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \ +# -e "s/#{mouse}/#[fg=$tmux_conf_theme_mouse_fg]#[bg=$tmux_conf_theme_mouse_bg]#[$tmux_conf_theme_mouse_attr]#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/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 +# if [ -z "$(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") +# -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_pid} #{b: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") +# -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_pid} #{b:pane_tty} $tmux_conf_theme_root #D)#[inherit]%g") # fi # # status_right=$(printf '%s' "$status_right" | awk \ @@ -1172,7 +1211,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # _battery_info # if [ "$charge" != 0 ]; then # case "$status_left $status_right" in -# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) +# *'#{battery_'*|*'#{?battery_'*) # status_left=$(echo "$status_left" | sed -E \ # -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ # -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ @@ -1185,12 +1224,14 @@ 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') -# 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" +# status_right="#(echo; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" # interval=60 -# if [ $_tmux_version -ge 302 ]; then -# 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" -# elif [ $_tmux_version -gt 204 ]; then -# status_right="#(printf '\n'; 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" +# if [ $_tmux_version -ge 320 ]; then +# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; 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 & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" +# elif [ $_tmux_version -ge 280 ]; then +# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; 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" +# elif [ $_tmux_version -gt 240 ]; then +# status_right="#(echo; 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" # else # status_right="#(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\")$status_right" # fi @@ -1199,47 +1240,53 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # fi # # case "$status_left $status_right" in -# *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*) +# *'#{username}'*|*'#{hostname}'*|*'#{hostname_full}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*|*'#{hostname_full_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 #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') +# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ +# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ +# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ +# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true 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 #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') +# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ +# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ +# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ +# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ +# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ +# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # ;; # esac # # _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 \ -# -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \ -# -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ -# -e '/@uptime_y/ s/@uptime_d/@uptime_dy/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_y/#\{\1@uptime_y/g' \ -# -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \ -# -e '/@uptime_y/ s/@uptime_d/@uptime_dy/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') +# *'#{uptime_'*|*'#{?uptime_'*) +# status_left=$(echo "$status_left" | perl -p -e ' +# ; s/#\{(\?)?uptime_y\b/#\{\1\@uptime_y/g +# ; s/#\{(\?)?uptime_d\b/#\{\1\@uptime_d/g +# ; s/\@uptime_d\b/\@uptime_dy/g if /\@uptime_y\b/ +# ; s/#\{(\?)?uptime_h\b/#\{\1\@uptime_h/g +# ; s/#\{(\?)?uptime_m\b/#\{\1\@uptime_m/g +# ; s/#\{(\?)?uptime_s\b/#\{\1\@uptime_s/g') +# status_right=$(echo "$status_right" | perl -p -e ' +# ; s/#\{(\?)?uptime_y\b/#\{\1\@uptime_y/g +# ; s/#\{(\?)?uptime_d\b/#\{\1\@uptime_d/g +# ; s/\@uptime_d\b/\@uptime_dy/g if /\@uptime_y\b/ +# ; s/#\{(\?)?uptime_h\b/#\{\1\@uptime_h/g +# ; s/#\{(\?)?uptime_m\b/#\{\1\@uptime_m/g +# ; s/#\{(\?)?uptime_s\b/#\{\1\@uptime_s/g') # interval=60 # case "$status_left $status_right" in # *'#{@uptime_s}'*) # interval=$(tmux show -gv status-interval) # ;; # esac -# if [ $_tmux_version -ge 302 ]; then -# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done" -# elif [ $_tmux_version -gt 204 ]; then -# status_right="#(printf '\n'; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" +# if [ $_tmux_version -ge 320 ]; then +# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" +# elif [ $_tmux_version -gt 280 ]; then +# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" +# elif [ $_tmux_version -gt 240 ]; then +# status_right="#(echo; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" # else # status_right="#(nice cut -c3- ~/.tmux.conf | sh -s _uptime)$status_right" # fi @@ -1248,16 +1295,18 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' # case "$status_left $status_right" in -# *'#{loadavg}'*) +# *'#{loadavg'*|*'#{?loadavg'*) # status_left=$(echo "$status_left" | sed -E \ # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # status_right=$(echo "$status_right" | sed -E \ # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # interval=$(tmux show -gv status-interval) -# if [ $_tmux_version -ge 302 ]; then -# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done" -# elif [ $_tmux_version -gt 204 ]; then -# status_right="#(printf '\n'; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" +# if [ $_tmux_version -ge 320 ]; then +# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" +# elif [ $_tmux_version -gt 280 ]; then +# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" +# elif [ $_tmux_version -gt 240 ]; then +# status_right="#(echo; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" # else # status_right="#(nice cut -c3- ~/.tmux.conf | sh -s _loadavg)$status_right" # fi @@ -1272,7 +1321,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # -- custom variables --------------------------------------------------- # # if [ -f ~/.tmux.conf.local ] && [ x"$(cut -c3- ~/.tmux.conf.local | sh 2>/dev/null -s printf probe)" = x"probe" ]; then -# replacements=$(perl -n -e 'print if s!^#\s+([^()\s]+)\s*\(\)\s*{\s*\n!s%#\\\{\1\\\}%#(cut -c3- ~/.tmux.conf.local | sh -s \1)%g; !p' < ~/.tmux.conf.local) +# replacements=$(perl -n -e 'print if s!^#\s+([^_][^()\s]+)\s*\(\)\s*{\s*\n!s%#\\\{\1((?:\\s+(?:[^\{\}]+?|#\\{(?:[^\{\}]+?)\}))*)\\\}%#(cut -c3- ~/.tmux.conf.local | sh -s \1\\1)%g; !p' < ~/.tmux.conf.local) # status_left=$(echo "$status_left" | perl -p -e "$replacements" || echo "$status_left") # status_right=$(echo "$status_right" | perl -p -e "$replacements" || echo "$status_right") # fi @@ -1303,19 +1352,99 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # setw -g clock-mode-style "$tmux_conf_theme_clock_style" # } # +# __apply_plugins() { +# window_active="$1" +# tmux_conf_update_plugins_on_launch="$2" +# tmux_conf_update_plugins_on_reload="$3" +# tmux_conf_uninstall_plugins_on_reload="$4" +# +# TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins} +# if [ -z "$(tmux show -gv '@plugin')" ] && [ -z "$(tmux show -gv '@tpm_plugins')" ]; then +# if _is_enabled "$tmux_conf_uninstall_plugins_on_reload" && [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then +# tmux display 'Uninstalling tpm and plugins...' +# rm -rf "$TMUX_PLUGIN_MANAGER_PATH" +# tmux display 'Done uninstalling tpm and plugins...' +# fi +# else +# if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then +# if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then +# install_tpm=true +# tmux display 'Installing tpm and plugins...' +# git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm" +# elif { [ -z "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_enabled "$tmux_conf_update_plugins_on_reload"; }; then +# update_tpm=true +# tmux display 'Updating tpm and plugins...' +# (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git fetch -q -p && git checkout -q master && git reset -q --hard origin/master) +# fi +# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then +# perl -0777 -p -i -e 's/git clone(?!\s+--depth\s+1)/git clone --depth 1/g +# ;s/(install_plugin(.(?!&))*)\n(\s+)done/\1&\n\3done\n\3wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh" +# perl -p -i -e 's/git submodule update --init --recursive(?!\s+--depth\s+1)/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh" +# perl -p -i -e 's,\$tmux_file\s+>/dev/null\s+2>\&1,$& || { tmux display "Plugin \$(basename \${plugin_path}) failed" && false; },' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/source_plugins.sh" +# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" +# fi +# if [ x"$update_tpm" = x"true" ]; then +# { +# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ +# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ +# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ +# tmux display 'Done updating tpm and plugins...' +# } || tmux display 'Failed updating tpm and plugins...' +# elif [ x"$install_tpm" = x"true" ]; then +# { +# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ +# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 +# tmux display 'Done installing tpm and plugins...' +# } || tmux display 'Failed installing tpm and plugins...' +# fi +# else +# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..." +# fi +# +# [ -z "$(tmux show -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I' +# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u' +# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u' +# [ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" ] && "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed" +# if [ $_tmux_version -gt 260 ]; then +# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin' +# fi +# fi +# +# if [ -z "$window_active" ] && [ $_tmux_version -lt 240 ]; then +# tmux run -b "sleep $(expr $(tmux display -p '#{display-time}') / 500) && tmux set display-time 3000 \; display 'This configuration will soon require tmux 2.4+' \; set -u display-time" +# fi +# } +# +# _apply_plugins() { +# tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true} +# tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true} +# tmux_conf_uninstall_plugins_on_reload=${tmux_conf_uninstall_plugins_on_reload:-true} +# tmux run -b "cut -c3- ~/.tmux.conf | sh -s __apply_plugins \"$window_active\" \"$tmux_conf_update_plugins_on_launch\" \"$tmux_conf_update_plugins_on_reload\" \"$tmux_conf_uninstall_plugins_on_reload\"" +# } +# # _apply_configuration() { # -# if ! command -v perl > /dev/null 2>&1; then -# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time' -# return -# fi -# if ! command -v sed > /dev/null 2>&1; then -# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time' -# return -# fi -# if ! command -v awk > /dev/null 2>&1; then -# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time' -# return +# window_active="$(tmux display -p '#{window_active}' 2>/dev/null || true)" +# if [ -z "$window_active" ]; then +# if ! command -v perl > /dev/null 2>&1; then +# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time \; run "sleep 3" \; kill-server' +# return +# fi +# if ! command -v sed > /dev/null 2>&1; then +# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time \; run "sleep 3" \; kill-server' +# return +# fi +# if ! command -v awk > /dev/null 2>&1; then +# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server' +# return +# fi +# if [ $_tmux_version -lt 230 ]; then +# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.3+" \; set -u display-time \; run "sleep 3" \; kill-server' +# return +# fi # fi # # # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard @@ -1345,6 +1474,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # # shellcheck disable=SC2046 # tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}') # wait +# +# _apply_plugins # } # # _urlview() { diff --git a/.tmux.conf.local b/.tmux.conf.local index 4ae12eb..515bc31 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -134,6 +134,8 @@ tmux_conf_theme_status_attr="none" # - #{circled_session_name} # - #{hostname} # - #{hostname_ssh} +# - #{hostname_full} +# - #{hostname_full_ssh} # - #{username} # - #{username_ssh} tmux_conf_theme_terminal_title="#h ❐ #S ● #I #W" @@ -144,6 +146,8 @@ tmux_conf_theme_terminal_title="#h ❐ #S ● #I #W" # - #{circled_session_name} # - #{hostname} # - #{hostname_ssh} +# - #{hostname_full} +# - #{hostname_full_ssh} # - #{username} # - #{username_ssh} tmux_conf_theme_window_status_fg="$tmux_conf_theme_colour_3" @@ -159,6 +163,8 @@ tmux_conf_theme_window_status_format="#I #W" # - #{circled_session_name} # - #{hostname} # - #{hostname_ssh} +# - #{hostname_full} +# - #{hostname_full_ssh} # - #{username} # - #{username_ssh} tmux_conf_theme_window_status_current_fg="$tmux_conf_theme_colour_1" @@ -188,10 +194,10 @@ 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="\uE0B0" # /!\ you don't need to install Powerline -#tmux_conf_theme_left_separator_sub="\uE0B1" # you only need fonts patched with -#tmux_conf_theme_right_separator_main="\uE0B2" # Powerline symbols or the standalone -#tmux_conf_theme_right_separator_sub="\uE0B3" # PowerlineSymbols.otf font, see README.md +#tmux_conf_theme_left_separator_main='\uE0B0' # /!\ you don't need to install Powerline +#tmux_conf_theme_left_separator_sub='\uE0B1' # you only need fonts patched with +#tmux_conf_theme_right_separator_main='\uE0B2' # Powerline symbols or the standalone +#tmux_conf_theme_right_separator_sub='\uE0B3' # PowerlineSymbols.otf font, see README.md # status left/right content: # - separate main sections with "|" @@ -205,7 +211,10 @@ tmux_conf_theme_right_separator_sub="|" # - #{circled_session_name} # - #{hostname_ssh} # - #{hostname} +# - #{hostname_full} +# - #{hostname_full_ssh} # - #{loadavg} +# - #{mouse} # - #{pairing} # - #{prefix} # - #{root} @@ -218,7 +227,7 @@ tmux_conf_theme_right_separator_sub="|" # - #{username} # - #{username_ssh} 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_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=" #{prefix}#{mouse}#{pairing}#{synchronized}#{?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="$tmux_conf_theme_colour_6,$tmux_conf_theme_colour_7,$tmux_conf_theme_colour_8" @@ -242,6 +251,12 @@ tmux_conf_theme_prefix_fg="none" tmux_conf_theme_prefix_bg="none" tmux_conf_theme_prefix_attr="none" +# mouse indicator +tmux_conf_theme_mouse="↗" # U+2197 +tmux_conf_theme_mouse_fg="none" +tmux_conf_theme_mouse_bg="none" +tmux_conf_theme_mouse_attr="none" + # root indicator tmux_conf_theme_root="!" tmux_conf_theme_root_fg="none" @@ -333,7 +348,50 @@ tmux_conf_copy_to_os_clipboard=false #set -g status-position top +# -- tpm ----------------------------------------------------------------------- + +# while I don't use tpm myself, many people requested official support so here +# is a seamless integration that automatically installs plugins in parallel + +# whenever a plugin introduces a variable to be used in 'status-left' or +# 'status-right', you can use it in 'tmux_conf_theme_status_left' and +# 'tmux_conf_theme_status_right' variables. + +# by default, launching tmux will update tpm and all plugins +# - true (default) +# - false +tmux_conf_update_plugins_on_launch=true + +# by default, reloading the configuration will update tpm and all plugins +# - true (default) +# - false +tmux_conf_update_plugins_on_reload=true + +# by default, reloading the configuration will uninstall tpm and plugins when no +# plugins are enabled +# - true (default) +# - false +tmux_conf_uninstall_plugins_on_reload=true + +# /!\ the tpm bindings differ slightly from upstream: +# - installing plugins: + I +# - uninstalling plugins: + Alt + u +# - updating plugins: + u + +# /!\ do not add set -g @plugin 'tmux-plugins/tpm' +# /!\ do not add run '~/.tmux/plugins/tpm/tpm' + +# to enable a plugin, use the 'set -g @plugin' syntax: +# visit https://github.com/tmux-plugins for available plugins +#set -g @plugin 'tmux-plugins/tmux-copycat' +#set -g @plugin 'tmux-plugins/tmux-cpu' +#set -g @plugin 'tmux-plugins/tmux-resurrect' +#set -g @plugin 'tmux-plugins/tmux-continuum' +#set -g @continuum-restore 'on' + + # -- custom variables ---------------------------------------------------------- + # to define a custom #{foo} variable, define a POSIX shell function between the # '# EOF' and the '# "$@"' lines. Please note that the opening brace { character # must be on the same line as the function name otherwise the parse won't detect @@ -345,13 +403,15 @@ tmux_conf_copy_to_os_clipboard=false # # /!\ do not remove the following line # EOF # +# # /!\ do not "uncomment" the functions: the leading "# " characters are needed +# # weather() { # curl -m 1 wttr.in?format=3 2>/dev/null # sleep 900 # sleep for 15 minutes, throttle network requests whatever the value of status-interval # } # # online() { -# ping -t 1 -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘' +# ping -c 1 1.1.1.1 >/dev/null 2>&1 && printf '✔' || printf '✘' # } # # "$@" diff --git a/README.md b/README.md index 52978a4..84263e5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Installation Requirements: - - tmux **`>= 2.1`** (soon `>= 2.4`) running inside Linux, Mac, OpenBSD, Cygwin + - tmux **`>= 2.3`** (soon `>= 2.4`) running inside Linux, Mac, OpenBSD, Cygwin or WSL - awk, perl and sed - outside of tmux, `$TERM` must be set to `xterm-256color` @@ -109,12 +109,12 @@ Features if available - laptop battery status line information - uptime status line information - - optional highlight of focused pane (tmux `>= 2.1`) + - optional highlight of focused pane - configurable new windows and panes behavior (optionally retain current path) - SSH/Mosh aware split pane (reconnects to remote server) - copy to OS clipboard (needs [`reattach-to-user-namespace`][reattach-to-user-namespace] on macOS, `xsel` or `xclip` on Linux) - - support for 4-digit hexadecimal Unicode characters (requires `perl` or Bash >= 4.1.2) + - support for 4-digit hexadecimal Unicode characters - [Facebook PathPicker][] integration if available - [Urlview][] integration if available @@ -299,7 +299,28 @@ tmux_conf_theme_status_right='#(echo foo %% bar)' ``` See `man 3 strftime`. -### Accessing the macOS clipboard from within tmux sessions +### Using TPM plugins + +This configuration now comes with built-in [TPM] support: +- use the `set -g @plugin ...` syntax to enable a plugin +- whenever a plugin introduces a variable to be used in `status-left` or + `status-right`, you can use it in `tmux_conf_theme_status_left` and + `tmux_conf_theme_status_right` variables, see instructions above 👆 +- ⚠️ do not add `set -g @plugin 'tmux-plugins/tpm'` +- ⚠️ do not add `run '~/.tmux/plugins/tpm/tpm'` to `~/.tmux.conf` or your +- `~/.tmux.conf.local` copy ← people who are used to alter + `.tmux.conf` to add TPM support will have to adapt their configuration + +⚠️ The TPM bindings differ slightly from upstream: + - installing plugins: ` + I` + - uninstalling plugins: ` + Alt + u` + - updating plugins: ` + u` + +See `~/.tmux.conf.local` for instructions. + +[TPM]: https://github.com/tmux-plugins/tpm + +### Accessing the macOS clipboard from within tmux sessions (tmux `< 2.6`) [Chris Johnsen created the `reattach-to-user-namespace` utility][reattach-to-user-namespace] that makes `pbcopy` and `pbpaste` work