1 # cat << EOF > /dev/null
2 # https://github.com/gpakosz/.tmux
3 # (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
4 # without any warranty.
5 # Copyright 2012— Gregory Pakosz (@gpakosz).
6 # /!\ do not edit this file
7 # instead, override settings in ~/.tmux.conf.local, see README.md
10 # -- general -------------------------------------------------------------------
12 set -g default-terminal "screen-256color" # colors!
14 set -s escape-time 10 # faster command sequences
15 set -sg repeat-time 600 # increase repeat timeout
16 set -s focus-events on
18 set -g prefix2 C-a # GNU-Screen compatible prefix
19 bind C-a send-prefix -2
21 set -q -g status-utf8 on # expect UTF-8 (tmux < 2.2)
24 set -g history-limit 5000 # boost history
27 bind e new-window -n "~/.tmux.conf.local" "sh -c '\${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'"
29 # reload configuration
30 bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
33 # -- display -------------------------------------------------------------------
35 set -g base-index 1 # start windows numbering at 1
36 setw -g pane-base-index 1 # make pane numbering consistent with windows
38 setw -g automatic-rename on # rename window to reflect current program
39 set -g renumber-windows on # renumber windows when a window is closed
41 set -g set-titles on # set terminal title
43 set -g display-panes-time 800 # slightly longer pane indicators display time
44 set -g display-time 1000 # slightly longer status messages display time
46 set -g status-interval 10 # redraw status line every 10 seconds
48 # clear both screen and history
49 bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
52 set -g monitor-activity on
53 set -g visual-activity off
56 # -- navigation ----------------------------------------------------------------
62 bind C-f command-prompt -p find-session 'switch-client -t %%'
64 # split current window horizontally
65 bind - split-window -v
66 # split current window vertically
67 bind _ split-window -h
70 bind -r h select-pane -L # move left
71 bind -r j select-pane -D # move down
72 bind -r k select-pane -U # move up
73 bind -r l select-pane -R # move right
74 bind > swap-pane -D # swap current pane with the next one
75 bind < swap-pane -U # swap current pane with the previous one
77 # maximize current pane
78 bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane "#{session_name}" #D'
81 bind -r H resize-pane -L 2
82 bind -r J resize-pane -D 2
83 bind -r K resize-pane -U 2
84 bind -r L resize-pane -R 2
89 bind -r C-h previous-window # select previous window
90 bind -r C-l next-window # select next window
91 bind Tab last-window # move to last active window
94 bind m run "cut -c3- ~/.tmux.conf | sh -s _toggle_mouse"
97 # -- urlview -------------------------------------------------------------------
99 bind U run "cut -c3- ~/.tmux.conf | sh -s _urlview #{pane_id}"
102 # -- facebook pathpicker -------------------------------------------------------
104 bind F run "cut -c3- ~/.tmux.conf | sh -s _fpp #{pane_id}"
107 # -- list choice (tmux < 2.4) --------------------------------------------------
109 # vi-choice is gone in tmux >= 2.4
110 run -b 'tmux bind -t vi-choice h tree-collapse 2> /dev/null || true'
111 run -b 'tmux bind -t vi-choice l tree-expand 2> /dev/null || true'
112 run -b 'tmux bind -t vi-choice K start-of-list 2> /dev/null || true'
113 run -b 'tmux bind -t vi-choice J end-of-list 2> /dev/null || true'
114 run -b 'tmux bind -t vi-choice H tree-collapse-all 2> /dev/null || true'
115 run -b 'tmux bind -t vi-choice L tree-expand-all 2> /dev/null || true'
116 run -b 'tmux bind -t vi-choice Escape cancel 2> /dev/null || true'
119 # -- edit mode (tmux < 2.4) ----------------------------------------------------
121 # vi-edit is gone in tmux >= 2.4
122 run -b 'tmux bind -ct vi-edit H start-of-line 2> /dev/null || true'
123 run -b 'tmux bind -ct vi-edit L end-of-line 2> /dev/null || true'
124 run -b 'tmux bind -ct vi-edit q cancel 2> /dev/null || true'
125 run -b 'tmux bind -ct vi-edit Escape cancel 2> /dev/null || true'
128 # -- copy mode -----------------------------------------------------------------
130 bind Enter copy-mode # enter copy mode
132 run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
133 run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
134 run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
135 run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
136 run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
137 run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
138 run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
139 run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
140 run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
141 run -b 'tmux bind -T copy-mode-vi H send -X start-of-line 2> /dev/null || true'
142 run -b 'tmux bind -t vi-copy L end-of-line 2> /dev/null || true'
143 run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
145 # copy to macOS clipboard
146 if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"'
147 if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
148 # copy to X11 clipboard
149 if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
150 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"'
151 # copy to Windows clipboard
152 if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
153 if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
156 # -- buffers -------------------------------------------------------------------
158 bind b list-buffers # list paste buffers
159 bind p paste-buffer # paste from the top paste buffer
160 bind P choose-buffer # choose which buffer to paste from
163 # -- user defined overrides ----------------------------------------------------
165 if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
168 # -- 8< ------------------------------------------------------------------------
170 run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
171 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'
176 # # exit the script if any statement returns a non-true return value
180 # export LC_NUMERIC=C
182 # if ! printf '' | sed -E 's///' 2>/dev/null; then
183 # if printf '' | sed -r 's///' 2>/dev/null; then
185 # n=$#; while [ "$n" -gt 0 ]; do arg=$1; shift; case $arg in -E*) arg=-r${arg#-E};; esac; set -- "$@" "$arg"; n=$(( n - 1 )); done
195 # ( ([ x"$1" = x"enabled" ] || [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ]) && return 0 ) || return 1
199 # circled_digits='⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳'
200 # if [ "$1" -le 20 ] 2>/dev/null; then
202 # eval set -- "$circled_digits"
209 # _decode_unicode_escapes() {
210 # printf '%s' "$*" | perl -CS -pe 's/(\\u([0-9A-Fa-f]{1,4})|\\U([0-9A-Fa-f]{1,8}))/chr(hex($2.$3))/eg' 2>/dev/null
214 # current_session=${1:-$(tmux display -p '#{session_name}')}
215 # current_pane=${2:-$(tmux display -p '#{pane_id}')}
217 # dead_panes=$(tmux list-panes -s -t "$current_session" -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -E -o '^1 %.+maximized.+$' || true)
218 # 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" )
220 # if [ -z "$restore" ]; then
221 # [ "$(tmux list-panes -t "$current_session:" | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return
222 # window=$(tmux new-window -t "$current_session:" -P "exec maximized... 2> /dev/null & tmux setw -t \"$current_session:\" remain-on-exit on; printf \"Pane has been maximized, press <prefix>+ to restore. %s\" '$current_pane'")
223 # window=${window%.*}
226 # while [ x"$(tmux list-panes -t "$window" -F '#{session_name}:#{window_index} #{pane_dead}' 2>/dev/null)" != x"$window 1" ] && [ "$retry" -ne 0 ]; do
228 # retry=$((retry - 1))
230 # if [ "$retry" -eq 0 ]; then
231 # tmux display 'Unable to maximize pane'
234 # new_pane=$(tmux display -t "$window" -p '#{pane_id}')
235 # tmux setw -t "$window" remain-on-exit off \; swap-pane -s "$current_pane" -t "$new_pane"
237 # $restore || tmux kill-pane
242 # old=$(tmux show -gv mouse)
245 # if [ "$old" = "on" ]; then
251 # tmux set -g mouse $new \;\
252 # display "mouse: $new"
258 # uname_s=$(uname -s)
261 # while IFS= read -r line; do
262 # if [ x"$discharging" != x"true" ]; then
263 # discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
265 # percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%')
266 # charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
267 # count=$((count + 1))
269 # $(pmset -g batt | grep 'InternalBattery')
273 # while IFS= read -r batpath; do
274 # grep -i -q device "$batpath/scope" 2> /dev/null && continue
276 # if [ x"$discharging" != x"true" ]; then
277 # discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
279 # bat_capacity="$batpath/capacity"
280 # if [ -r "$bat_capacity" ]; then
281 # charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + capacity / 100 }')
283 # bat_energy_full="$batpath/energy_full"
284 # bat_energy_now="$batpath/energy_now"
285 # if [ -r "$bat_energy_full" ] && [ -r "$bat_energy_now" ]; then
286 # charge=$(awk -v charge="$charge" -v energy_now="$(cat "$bat_energy_now")" -v energy_full="$(cat "$bat_energy_full")" 'BEGIN { print charge + energy_now / energy_full }')
289 # count=$((count + 1))
291 # $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
294 # *CYGWIN*|*MSYS*|*MINGW*)
295 # while IFS= read -r line; do
296 # [ -z "$line" ] && continue
297 # if [ x"$discharging" != x"true" ]; then
298 # discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
300 # charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }')
301 # count=$((count + 1))
303 # $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining | tr -d '\r' | tail -n +2)
307 # for batid in 0 1 2; do
308 # sysctl -n "hw.sensors.acpibat$batid.raw0" 2>&1 | grep -q 'not found' && continue
309 # if [ x"$discharging" != x"true" ]; then
310 # discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
312 # if sysctl -n "hw.sensors.acpibat$batid" | grep -q amphour; then
313 # charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
315 # charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.watthour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.watthour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
317 # count=$((count + 1))
321 # [ "$count" -ne 0 ] && charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }')
322 # if [ "$charge" -eq 0 ]; then
323 # tmux set -ug '@battery_status' \;\
324 # set -ug '@battery_bar' \;\
325 # set -ug '@battery_hbar' \;\
326 # set -ug '@battery_vbar' \;\
327 # set -ug '@battery_percentage'
331 # variables=$(tmux show -gqv '@battery_bar_symbol_full' \;\
332 # show -gqv '@battery_bar_symbol_empty' \;\
333 # show -gqv '@battery_bar_length' \;\
334 # show -gqv '@battery_bar_palette' \;\
335 # show -gqv '@battery_hbar_palette' \;\
336 # show -gqv '@battery_vbar_palette' \;\
337 # show -gqv '@battery_status_charging' \;\
338 # show -gqv '@battery_status_discharging')
339 # # shellcheck disable=SC2086
340 # { set -f; IFS="$__newline"; set -- $variables; unset IFS; set +f; }
342 # battery_bar_symbol_full=$1
343 # battery_bar_symbol_empty=$2
344 # battery_bar_length=$3
345 # battery_bar_palette=$4
346 # battery_hbar_palette=$5
347 # battery_vbar_palette=$6
348 # battery_status_charging=$7
349 # battery_status_discharging=$8
351 # if [ x"$battery_bar_length" = x"auto" ]; then
352 # columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)
353 # if [ "$columns" -ge 80 ]; then
354 # battery_bar_length=10
356 # battery_bar_length=5
360 # if [ x"$discharging" = x"true" ]; then
361 # battery_status="$battery_status_discharging"
363 # battery_status="$battery_status_charging"
366 # if echo "$battery_bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
367 # # shellcheck disable=SC2086
368 # { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
370 # battery_bg=${2:-none}
371 # [ x"$palette_style" = x"gradient" ] && \
372 # palette="196 202 208 214 220 226 190 154 118 82 46"
373 # [ x"$palette_style" = x"heat" ] && \
374 # palette="243 245 247 144 143 142 184 214 208 202 196"
376 # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
377 # eval set -- "$palette"
379 # full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
380 # battery_bar="#[bg=$battery_bg]"
381 # # shellcheck disable=SC2046
382 # [ "$full" -gt 0 ] && \
383 # battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
384 # # shellcheck disable=SC2046
385 # empty=$((battery_bar_length - full))
386 # # shellcheck disable=SC2046
387 # [ "$empty" -gt 0 ] && \
388 # battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
389 # eval battery_bar="$battery_bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
390 # elif echo "$battery_bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
391 # # shellcheck disable=SC2086
392 # { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
394 # battery_empty_fg=$2
397 # full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
398 # [ x"$battery_bg" != x"none" ] && \
399 # battery_bar="#[bg=$battery_bg]"
400 # #shellcheck disable=SC2046
401 # [ "$full" -gt 0 ] && \
402 # battery_bar="$battery_bar#[fg=$battery_full_fg]$(printf "%0.s$battery_bar_symbol_full" $(seq 1 "$full"))"
403 # empty=$((battery_bar_length - full))
404 # #shellcheck disable=SC2046
405 # [ "$empty" -gt 0 ] && \
406 # battery_bar="$battery_bar#[fg=$battery_empty_fg]$(printf "%0.s$battery_bar_symbol_empty" $(seq 1 "$empty"))" && \
407 # battery_bar="$battery_bar#[fg=$battery_empty_fg]"
410 # if echo "$battery_hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
411 # # shellcheck disable=SC2086
412 # { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
414 # [ x"$palette_style" = x"gradient" ] && \
415 # palette="196 202 208 214 220 226 190 154 118 82 46"
416 # [ x"$palette_style" = x"heat" ] && \
417 # palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
419 # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
420 # eval set -- "$palette"
422 # full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
423 # eval battery_hbar_fg="colour\${$((full == 0 ? 1 : full))}"
424 # elif echo "$battery_hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
425 # # shellcheck disable=SC2086
426 # { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
428 # # shellcheck disable=SC2046
429 # eval $(awk "BEGIN { printf \"battery_hbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
432 # eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
433 # # shellcheck disable=SC2046
434 # eval $(awk "BEGIN { printf \"battery_hbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
435 # battery_hbar="#[fg=${battery_hbar_fg?}]${battery_hbar_symbol?}"
437 # if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
438 # # shellcheck disable=SC2086
439 # { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
441 # [ x"$palette_style" = x"gradient" ] && \
442 # palette="196 202 208 214 220 226 190 154 118 82 46"
443 # [ x"$palette_style" = x"heat" ] && \
444 # palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
446 # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
447 # eval set -- "$palette"
449 # full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
450 # eval battery_vbar_fg="colour\${$((full == 0 ? 1 : full))}"
451 # elif echo "$battery_vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
452 # # shellcheck disable=SC2086
453 # { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
455 # # shellcheck disable=SC2046
456 # eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
459 # eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
460 # # shellcheck disable=SC2046
461 # eval $(awk "BEGIN { printf \"battery_vbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
462 # battery_vbar="#[fg=${battery_vbar_fg?}]${battery_vbar_symbol?}"
464 # battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
466 # tmux set -g '@battery_status' "$battery_status" \;\
467 # set -g '@battery_bar' "$battery_bar" \;\
468 # set -g '@battery_hbar' "$battery_hbar" \;\
469 # set -g '@battery_vbar' "$battery_vbar" \;\
470 # set -g '@battery_percentage' "$battery_percentage"
475 # uname -s | grep -q "CYGWIN" && cygwin=true
477 # if [ x"$cygwin" = x"true" ]; then
478 # ps -af | tail -n +2 | awk -v tty="$tty" '
479 # ((/ssh/ && !/-W/) || !/ssh/) && $4 == tty {
480 # user[$2] = $1; parent[$2] = $3; child[$3] = $2
489 # if (!(i in child) && j != 1)
491 # file = "/proc/" i "/cmdline"; getline command < file; close(file)
492 # gsub(/\0/, " ", command)
493 # print i, user[i], command
500 # ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk '
501 # NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) {
502 # user[$2] = $1; parent[$2] = $3; child[$3] = $2; for (i = 4 ; i <= NF; ++i) command[$2] = i > 4 ? command[$2] FS $i : $i
511 # if (!(i in child) && j != 1)
513 # print i, user[i], command[i]
522 # _ssh_or_mosh_args() {
523 # args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1=""; print $0; exit }')
524 # if [ -z "$args" ]; then
525 # args=$(printf '%s' "$1" | grep 'mosh-client' | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g')
528 # printf '%s' "$args"
532 # tty=${1:-$(tmux display -p '#{pane_tty}')}
535 # tty_info=$(_tty_info "$tty")
536 # command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
538 # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
539 # if [ -n "$ssh_or_mosh_args" ]; then
540 # # shellcheck disable=SC2086
541 # username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }')
542 # # shellcheck disable=SC2086
543 # [ -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 }')
545 # if ! _is_enabled "$ssh_only"; then
546 # username=$(printf '%s' "$tty_info" | cut -d' ' -f2)
550 # printf '%s' "$username"
554 # tty=${1:-$(tmux display -p '#{pane_tty}')}
557 # tty_info=$(_tty_info "$tty")
558 # command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
560 # ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
561 # if [ -n "$ssh_or_mosh_args" ]; then
562 # # shellcheck disable=SC2086
563 # hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^hostname / { print $2 }')
564 # # shellcheck disable=SC2086
565 # [ -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 }')
566 # #shellcheck disable=SC1004
567 # hostname=$(echo "$hostname" | awk '\
569 # if ($1~/^[0-9.:]+$/) \
572 # split($1, a, ".") ; print a[1] \
575 # if ! _is_enabled "$ssh_only"; then
576 # hostname=$(command hostname -s)
580 # printf '%s' "$hostname"
584 # tty=${1:-$(tmux display -p '#{pane_tty}')}
585 # username=$(_username "$tty" false)
587 # if [ x"$username" = x"root" ]; then
588 # tmux show -gqv '@root'
595 # case $(uname -s) in
597 # boot=$(sysctl -q -n kern.boottime | awk -F'[ ,:]+' '{ print $4 }')
600 # *Linux*|*CYGWIN*|*MSYS*|*MINGW*)
602 # now=$(cut -d' ' -f1 < /proc/uptime)
605 # boot=$(sysctl -n kern.boottime)
608 # # shellcheck disable=SC1004
609 # awk -v boot="$boot" -v now="$now" '
611 # uptime = now - boot
612 # y = int(uptime / 31536000)
613 # dy = int(uptime / 86400) % 365
614 # d = int(uptime / 86400)
615 # h = int(uptime / 3600) % 24
616 # m = int(uptime / 60) % 60
617 # s = int(uptime) % 60
619 # system("tmux set -g @uptime_y " y + 0 " \\; " \
620 # "set -g @uptime_dy " dy + 0 " \\; " \
621 # "set -g @uptime_d " d + 0 " \\; " \
622 # "set -g @uptime_h " h + 0 " \\; " \
623 # "set -g @uptime_m " m + 0 " \\; " \
624 # "set -g @uptime_s " s + 0)
629 # case $(uname -s) in
631 # tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f2)"
634 # tmux set -g @loadavg "$(cut -d' ' -f1 < /proc/loadavg)"
637 # tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f1)"
643 # tty=${1:-$(tmux display -p '#{pane_tty}')}
646 # tty_info=$(_tty_info "$tty")
647 # command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
651 # # shellcheck disable=SC2046
652 # tmux split-window "$@" mosh $(echo "$command" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/')
655 # # shellcheck disable=SC2046
656 # tmux split-window "$@" $(echo "$command" | sed -e 's/;/\\;/g')
659 # tmux split-window "$@"
663 # _apply_overrides() {
664 # tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-false}
665 # if _is_enabled "$tmux_conf_theme_24b_colour"; then
670 # tmux set-option -ga terminal-overrides ",*256col*:Tc"
676 # _apply_bindings() {
677 # cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
679 # tmux list-keys | grep -vF 'tmux.conf.local' | grep -E '(new-window|split(-|_)window|new-session|copy-selection|copy-pipe)' > "$cfg"
681 # # tmux 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the
682 # # output of list-keys can be truncated
683 # perl -p -i -e "s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}\"/g" "$cfg"
685 # tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false}
686 # if _is_enabled "$tmux_conf_new_window_retain_current_path"; then
688 # -e "s/\b(new-window)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
690 # -e "s/\bnew-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/new-window -c '#{pane_current_path}'/g" \
693 # perl -p -i -e "s/\bnew-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" "$cfg"
696 # tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-false}
697 # if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
698 # perl -p -i -e "s/\bsplit-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/split-window -c '#{pane_current_path}'/g" "$cfg"
700 # perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" "$cfg"
703 # tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false}
704 # if _is_enabled "$tmux_conf_new_pane_reconnect_ssh"; then
705 # if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
707 # -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1\3 -c #\{pane_current_path\}'/g" \
709 # -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1 -c \\\\\"#{pane_current_path}\\\\\"\"/g" \
713 # -e "s/\bsplit-window\b([^;}\n]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1'/g" \
715 # -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1\"/g" \
719 # if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
720 # perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*?)\s+-c\s+#\{pane_current_path\}\2/split-window\3 -c '#{pane_current_path}'/g" "$cfg"
722 # perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*)\2/split-window\3/g" "$cfg"
726 # tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false}
727 # if _is_enabled "$tmux_conf_new_session_prompt"; then
729 # -e "s/(?<!command-prompt -p )\b(new-session)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
731 # -e "s/(?<!\bcommand-prompt -p )\bnew-session\b(?! -s)/command-prompt -p new-session 'new-session -s \"%%\"'/g" \
734 # perl -p -i -e "s/\bcommand-prompt\s+-p\s+new-session\s+'new-session\s+-s\s+\"%%\"'/new-session/g" "$cfg"
737 # tmux_conf_copy_to_os_clipboard=${tmux_conf_copy_to_os_clipboard:-false}
738 # command -v pbcopy > /dev/null 2>&1 && command='pbcopy'
739 # command -v reattach-to-user-namespace > /dev/null 2>&1 && command='reattach-to-user-namespace pbcopy'
740 # command -v xsel > /dev/null 2>&1 && command='xsel -i -b'
741 # ! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1 && command='xclip -i -selection clipboard > \/dev\/null 2>\&1'
742 # command -v clip.exe > /dev/null 2>&1 && command='clip\.exe'
743 # [ -c /dev/clipboard ] && command='cat > \/dev\/clipboard'
745 # if [ -n "$command" ]; then
746 # if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then
747 # perl -p -i -e "s/\bcopy-selection(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg"
749 # perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2/copy-selection\1/g" "$cfg"
753 # # until tmux >= 3.0, output of tmux list-keys can't be consumed back by tmux source-file without applying some escapings
755 # '{i = $2 == "-T" ? 4 : 5; gsub(/^[;]$/, "\\\\&", $i); gsub(/^[$"#~]$/, "'"'"'&'"'"'", $i); gsub(/^['"'"']$/, "\"&\"", $i); print}' > "$cfg.in"
757 # # ignore bindings with errors
758 # if ! tmux source-file "$cfg.in"; then
759 # verbose_flag=$(tmux source-file -v /dev/null 2> /dev/null && printf -- '-v' || true)
760 # while ! out=$(tmux source-file "$verbose_flag" "$cfg.in"); do
761 # line=$(printf "%s" "$out" | tail -1 | cut -d':' -f2)
762 # perl -n -i -e "if ($. != $line) { print }" "$cfg.in"
769 # # -- panes -------------------------------------------------------------
771 # tmux_conf_theme_window_fg=${tmux_conf_theme_window_fg:-default}
772 # tmux_conf_theme_window_bg=${tmux_conf_theme_window_bg:-default}
773 # tmux_conf_theme_highlight_focused_pane=${tmux_conf_theme_highlight_focused_pane:-false}
774 # tmux_conf_theme_focused_pane_fg=${tmux_conf_theme_focused_pane_fg:-'default'} # default
775 # tmux_conf_theme_focused_pane_bg=${tmux_conf_theme_focused_pane_bg:-'#0087d7'} # light blue
777 # # tmux 1.9 doesn't really like set -q
778 # if tmux show -g -w | grep -q window-style; then
779 # tmux setw -g window-style "fg=$tmux_conf_theme_window_fg,bg=$tmux_conf_theme_window_bg"
781 # if _is_enabled "$tmux_conf_theme_highlight_focused_pane"; then
782 # tmux setw -g window-active-style "fg=$tmux_conf_theme_focused_pane_fg,bg=$tmux_conf_theme_focused_pane_bg"
784 # tmux setw -g window-active-style default
788 # tmux_conf_theme_pane_border_style=${tmux_conf_theme_pane_border_style:-thin}
789 # tmux_conf_theme_pane_border=${tmux_conf_theme_pane_border:-'#444444'} # light gray
790 # tmux_conf_theme_pane_active_border=${tmux_conf_theme_pane_active_border:-'#00afff'} # light blue
791 # tmux_conf_theme_pane_border_fg=${tmux_conf_theme_pane_border_fg:-$tmux_conf_theme_pane_border}
792 # tmux_conf_theme_pane_active_border_fg=${tmux_conf_theme_pane_active_border_fg:-$tmux_conf_theme_pane_active_border}
793 # case "$tmux_conf_theme_pane_border_style" in
795 # tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-$tmux_conf_theme_pane_border_fg}
796 # tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-$tmux_conf_theme_pane_active_border_fg}
799 # tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-'default'}
800 # tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-'default'}
803 # 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"
805 # tmux_conf_theme_pane_indicator=${tmux_conf_theme_pane_indicator:-'#00afff'} # light blue
806 # tmux_conf_theme_pane_active_indicator=${tmux_conf_theme_pane_active_indicator:-'#00afff'} # light blue
808 # tmux set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator"
810 # # -- status line -------------------------------------------------------
812 # tmux_conf_theme_left_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_main-}")
813 # tmux_conf_theme_left_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_sub-|}")
814 # tmux_conf_theme_right_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_main-}")
815 # tmux_conf_theme_right_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_sub-|}")
817 # tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-'#000000'} # black
818 # tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-'#ffff00'} # yellow
819 # tmux_conf_theme_message_attr=${tmux_conf_theme_message_attr:-'bold'}
820 # tmux set -g message-style "fg=$tmux_conf_theme_message_fg,bg=$tmux_conf_theme_message_bg,$tmux_conf_theme_message_attr"
822 # tmux_conf_theme_message_command_fg=${tmux_conf_theme_message_command_fg:-'#ffff00'} # yellow
823 # tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-'#000000'} # black
824 # tmux_conf_theme_message_command_attr=${tmux_conf_theme_message_command_attr:-'bold'}
825 # 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"
827 # tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-'#000000'} # black
828 # tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-'#ffff00'} # yellow
829 # tmux_conf_theme_mode_attr=${tmux_conf_theme_mode_attr:-'bold'}
830 # tmux setw -g mode-style "fg=$tmux_conf_theme_mode_fg,bg=$tmux_conf_theme_mode_bg,$tmux_conf_theme_mode_attr"
832 # tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-'#8a8a8a'} # white
833 # tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-'#080808'} # dark gray
834 # tmux_conf_theme_status_attr=${tmux_conf_theme_status_attr:-'none'}
835 # tmux set -g status-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\
836 # set -g status-left-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr" \;\
837 # set -g status-right-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr"
839 # tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-'#h ❐ #S ● #I #W'}
841 # tmux_conf_theme_terminal_title=$(echo "$tmux_conf_theme_terminal_title" | sed \
842 # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
843 # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
844 # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
845 # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
846 # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
847 # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
848 # tmux set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")"
850 # tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-'#8a8a8a'} # white
851 # tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-'#080808'} # dark gray
852 # tmux_conf_theme_window_status_attr=${tmux_conf_theme_window_status_attr:-'none'}
853 # tmux_conf_theme_window_status_format=${tmux_conf_theme_window_status_format:-'#I #W'}
855 # tmux_conf_theme_window_status_current_fg=${tmux_conf_theme_window_status_current_fg:-'#000000'} # black
856 # tmux_conf_theme_window_status_current_bg=${tmux_conf_theme_window_status_current_bg:-'#00afff'} # light blue
857 # tmux_conf_theme_window_status_current_attr=${tmux_conf_theme_window_status_current_attr:-'bold'}
858 # tmux_conf_theme_window_status_current_format=${tmux_conf_theme_window_status_current_format:-'#I #W'}
859 # if [ x"$(tmux show -g -v status-justify)" = x"right" ]; then
860 # tmux_conf_theme_window_status_current_format="#[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_window_status_bg]$tmux_conf_theme_right_separator_main#[fg=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr] $tmux_conf_theme_window_status_current_format #[fg=$tmux_conf_theme_window_status_bg,bg=$tmux_conf_theme_window_status_current_bg,none]$tmux_conf_theme_right_separator_main"
862 # 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=$tmux_conf_theme_window_status_current_fg,bg=$tmux_conf_theme_window_status_current_bg,$tmux_conf_theme_window_status_current_attr] $tmux_conf_theme_window_status_current_format #[fg=$tmux_conf_theme_window_status_current_bg,bg=$tmux_conf_theme_status_bg,none]$tmux_conf_theme_left_separator_main"
865 # tmux_conf_theme_window_status_format=$(echo "$tmux_conf_theme_window_status_format" | sed \
866 # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
867 # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
868 # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
869 # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
870 # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
871 # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
872 # tmux_conf_theme_window_status_current_format=$(echo "$tmux_conf_theme_window_status_current_format" | sed \
873 # -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
874 # -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
875 # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
876 # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
877 # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
878 # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
880 # 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" \;\
881 # setw -g window-status-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_format")" \;\
882 # 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" \;\
883 # setw -g window-status-current-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_current_format")"
885 # tmux_conf_theme_window_status_activity_fg=${tmux_conf_theme_window_status_activity_fg:-'default'}
886 # tmux_conf_theme_window_status_activity_bg=${tmux_conf_theme_window_status_activity_bg:-'default'}
887 # tmux_conf_theme_window_status_activity_attr=${tmux_conf_theme_window_status_activity_attr:-'underscore'}
888 # 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"
890 # tmux_conf_theme_window_status_bell_fg=${tmux_conf_theme_window_status_bell_fg:-'#ffff00'} # yellow
891 # tmux_conf_theme_window_status_bell_bg=${tmux_conf_theme_window_status_bell_bg:-'default'}
892 # tmux_conf_theme_window_status_bell_attr=${tmux_conf_theme_window_status_bell_attr:-'blink,bold'}
893 # 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"
895 # tmux_conf_theme_window_status_last_fg=${tmux_conf_theme_window_status_last_fg:-'#00afff'} # light blue
896 # tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-'default'}
897 # tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-'none'}
898 # 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"
902 # tmux_conf_theme_pairing=${tmux_conf_theme_pairing:-'👓'} # U+1F453
903 # tmux_conf_theme_pairing_fg=${tmux_conf_theme_pairing_fg:-'#e4e4e4'} # white
904 # tmux_conf_theme_pairing_bg=${tmux_conf_theme_pairing_bg:-'none'}
905 # tmux_conf_theme_pairing_attr=${tmux_conf_theme_pairing_attr:-'none'}
907 # tmux_conf_theme_prefix=${tmux_conf_theme_prefix:-'⌨'} # U+2328
908 # tmux_conf_theme_prefix_fg=${tmux_conf_theme_prefix_fg:-'#e4e4e4'} # white
909 # tmux_conf_theme_prefix_bg=${tmux_conf_theme_prefix_bg:-'none'}
910 # tmux_conf_theme_prefix_attr=${tmux_conf_theme_prefix_attr:-'none'}
912 # tmux_conf_theme_root=${tmux_conf_theme_root:-'!'}
913 # tmux_conf_theme_root_fg=${tmux_conf_theme_root_fg:-'none'}
914 # tmux_conf_theme_root_bg=${tmux_conf_theme_root_bg:-'none'}
915 # tmux_conf_theme_root_attr=${tmux_conf_theme_root_attr:-'bold,blink'}
917 # tmux_conf_theme_synchronized=${tmux_conf_theme_synchronized:-'🔒'} # U+1F512
918 # tmux_conf_theme_synchronized_fg=${tmux_conf_theme_synchronized_fg:-'none'}
919 # tmux_conf_theme_synchronized_bg=${tmux_conf_theme_synchronized_bg:-'none'}
920 # tmux_conf_theme_synchronized_attr=${tmux_conf_theme_synchronized_attr:-'none'}
922 # # -- status left style
924 # tmux_conf_theme_status_left=${tmux_conf_theme_status_left-' ❐ #S '}
925 # tmux_conf_theme_status_left_fg=${tmux_conf_theme_status_left_fg:-'#000000,#e4e4e4,#e4e4e4'} # black, white , white
926 # tmux_conf_theme_status_left_bg=${tmux_conf_theme_status_left_bg:-'#ffff00,#ff00af,#00afff'} # yellow, pink, white blue
927 # tmux_conf_theme_status_left_attr=${tmux_conf_theme_status_left_attr:-'bold,none,none'}
929 # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
930 # -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")
932 # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
933 # -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")
935 # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
936 # -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")
938 # tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
939 # -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")
941 # if [ -n "$tmux_conf_theme_status_left" ]; then
942 # status_left=$(awk \
943 # -v fg_="$tmux_conf_theme_status_left_fg" \
944 # -v bg_="$tmux_conf_theme_status_left_bg" \
945 # -v attr_="$tmux_conf_theme_status_left_attr" \
946 # -v mainsep="$tmux_conf_theme_left_separator_main" \
947 # -v subsep="$tmux_conf_theme_left_separator_sub" '
948 # function subsplit(s, l, i, a, r)
950 # l = split(s, a, ",")
951 # for (i = 1; i <= l; ++i)
953 # o = split(a[i], _, "(") - 1
954 # c = split(a[i], _, ")") - 1
956 # o_ = split(a[i], _, "{") - 1
957 # c_ = split(a[i], _, "}") - 1
959 # o__ = split(a[i], _, "[") - 1
960 # c__ = split(a[i], _, "]") - 1
961 # open__ += o__ - c__
964 # r = sprintf("%s%s", r, a[i])
965 # else if (open || open_ || open__)
966 # r = sprintf("%s%s,", r, a[i])
968 # r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
971 # gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
976 # l1 = split(fg_, fg, ",")
977 # l2 = split(bg_, bg, ",")
978 # l3 = split(attr_, attr, ",")
979 # l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3)
982 # for (i = j = 1; i <= NF; ++i)
984 # if (open || open_ || open__)
985 # printf "|%s", subsplit($i)
989 # 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)
991 # printf "#[fg=%s,bg=%s,%s]%s", fg[j], bg[j], attr[j], subsplit($i)
994 # if (!open && !open_ && !open__)
1000 # printf "#[fg=%s,bg=%s,none]%s", bg[j_], "default", mainsep
1002 # $tmux_conf_theme_status_left
1007 # status_left="$status_left "
1009 # # -- status right style
1011 # tmux_conf_theme_status_right=${tmux_conf_theme_status_right-'#{pairing}#{prefix} #{battery_status} #{battery_bar} #{battery_percentage} , %R , %d %b | #{username} | #{hostname} '}
1012 # tmux_conf_theme_status_right_fg=${tmux_conf_theme_status_right_fg:-'#8a8a8a,#e4e4e4,#000000'} # light gray, white, black
1013 # tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-'#080808,#d70000,#e4e4e4'} # dark gray, red, white
1014 # tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-'none,none,bold'}
1016 # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
1017 # -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")
1019 # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
1020 # -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")
1022 # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
1023 # -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")
1025 # tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
1026 # -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")
1028 # if [ -n "$tmux_conf_theme_status_right" ]; then
1029 # status_right=$(awk \
1030 # -v fg_="$tmux_conf_theme_status_right_fg" \
1031 # -v bg_="$tmux_conf_theme_status_right_bg" \
1032 # -v attr_="$tmux_conf_theme_status_right_attr" \
1033 # -v mainsep="$tmux_conf_theme_right_separator_main" \
1034 # -v subsep="$tmux_conf_theme_right_separator_sub" '
1035 # function subsplit(s, l, i, a, r)
1037 # l = split(s, a, ",")
1038 # for (i = 1; i <= l; ++i)
1040 # o = split(a[i], _, "(") - 1
1041 # c = split(a[i], _, ")") - 1
1043 # o_ = split(a[i], _, "{") - 1
1044 # c_ = split(a[i], _, "}") - 1
1046 # o__ = split(a[i], _, "[") - 1
1047 # c__ = split(a[i], _, "]") - 1
1048 # open__ += o__ - c__
1051 # r = sprintf("%s%s", r, a[i])
1052 # else if (open || open_ || open__)
1053 # r = sprintf("%s%s,", r, a[i])
1055 # r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
1058 # gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
1063 # l1 = split(fg_, fg, ",")
1064 # l2 = split(bg_, bg, ",")
1065 # l3 = split(attr_, attr, ",")
1066 # l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3)
1069 # for (i = j = 1; i <= NF; ++i)
1071 # if (open_ || open || open__)
1072 # printf "|%s", subsplit($i)
1074 # 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)
1076 # if (!open && !open_ && !open__)
1083 # $tmux_conf_theme_status_right
1090 # tmux set -g '@root' "$tmux_conf_theme_root"
1092 # tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-'◼'}
1093 # tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-'◻'}
1094 # tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-'auto'}
1095 # tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-'gradient'}
1096 # tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-'gradient'} # red, orange, green
1097 # tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-'gradient'} # red, orange, green
1098 # tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-'↑'} # U+2191
1099 # tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-'↓'} # U+2193
1101 # case "$status_left $status_right" in
1102 # *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*)
1103 # status_left=$(echo "$status_left" | sed -E \
1104 # -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
1105 # -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
1106 # -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
1107 # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
1108 # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
1109 # status_right=$(echo "$status_right" | sed -E \
1110 # -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
1111 # -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
1112 # -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
1113 # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
1114 # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
1116 # tmux set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\
1117 # set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\
1118 # set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\
1119 # set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\
1120 # set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\
1121 # set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\
1122 # set -g '@battery_status_charging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_charging")" \;\
1123 # set -g '@battery_status_discharging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging")"
1124 # status_right="#(cut -c3- ~/.tmux.conf | sh -s _battery)$status_right"
1128 # case "$status_left $status_right" in
1129 # *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*)
1130 # status_left=$(echo "$status_left" | sed \
1131 # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
1132 # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
1133 # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
1134 # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
1135 # status_right=$(echo "$status_right" | sed \
1136 # -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
1137 # -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
1138 # -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
1139 # -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
1143 # case "$status_left $status_right" in
1144 # *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*|*'#{uptime_s}'*)
1145 # status_left=$(echo "$status_left" | sed -E \
1146 # -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \
1147 # -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \
1148 # -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \
1149 # -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \
1150 # -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \
1151 # -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g')
1152 # status_right=$(echo "$status_right" | sed -E \
1153 # -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \
1154 # -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \
1155 # -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \
1156 # -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \
1157 # -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \
1158 # -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g')
1159 # status_right="#(cut -c3- ~/.tmux.conf | sh -s _uptime)$status_right"
1163 # case "$status_left $status_right" in
1165 # status_left=$(echo "$status_left" | sed -E \
1166 # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
1167 # status_right=$(echo "$status_right" | sed -E \
1168 # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
1169 # status_right="#(cut -c3- ~/.tmux.conf | sh -s _loadavg)$status_right"
1173 # status_left=$(echo "$status_left" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g')
1174 # status_right=$(echo "$status_right" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g')
1176 # tmux set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\
1177 # set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")"
1179 # # -- clock -------------------------------------------------------------
1181 # tmux_conf_theme_clock_colour=${tmux_conf_theme_clock_colour:-'#00afff'} # light blue
1182 # tmux_conf_theme_clock_style=${tmux_conf_theme_clock_style:-'24'}
1183 # tmux setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\
1184 # setw -g clock-mode-style "$tmux_conf_theme_clock_style"
1187 # _apply_configuration() {
1189 # if ! command -v perl > /dev/null 2>&1; then
1190 # tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time'
1193 # if ! command -v sed > /dev/null 2>&1; then
1194 # tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time'
1197 # if ! command -v awk > /dev/null 2>&1; then
1198 # tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time'
1202 # # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
1203 # if command -v reattach-to-user-namespace > /dev/null 2>&1; then
1204 # default_shell="$(tmux show -gv default-shell)"
1205 # case "$default_shell" in
1207 # tmux set -g default-command "reattach-to-user-namespace -l $default_shell"
1210 # tmux set -g default-command "exec $default_shell... 2> /dev/null & reattach-to-user-namespace -l $default_shell"
1218 # for name in $(printenv | grep -E -o '^tmux_conf_[^=]+'); do tmux setenv -gu "$name"; done;
1222 # tmux capture-pane -J -S - -E - -b "urlview-$1" -t "$1"
1223 # tmux split-window "tmux show-buffer -b urlview-$1 | urlview || true; tmux delete-buffer -b urlview-$1"
1227 # tmux capture-pane -J -S - -E - -b "fpp-$1" -t "$1"
1228 # tmux split-window "tmux show-buffer -b fpp-$1 | fpp || true; tmux delete-buffer -b fpp-$1"