cambios en la charla y codi
[dotfilesold/.git] / .tmux / .tmux.conf
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
8
9
10 # -- general -------------------------------------------------------------------
11
12 set -g default-terminal "screen-256color" # colors!
13 setw -g xterm-keys on
14 set -s escape-time 10                     # faster command sequences
15 set -sg repeat-time 600                   # increase repeat timeout
16 set -s focus-events on
17
18 set -g prefix2 C-a                        # GNU-Screen compatible prefix
19 bind C-a send-prefix -2
20
21 set -q -g status-utf8 on                  # expect UTF-8 (tmux < 2.2)
22 setw -q -g utf8 on
23
24 set -g history-limit 5000                 # boost history
25
26 # edit configuration
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\"'"
28
29 # reload configuration
30 bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
31
32
33 # -- display -------------------------------------------------------------------
34
35 set -g base-index 1           # start windows numbering at 1
36 setw -g pane-base-index 1     # make pane numbering consistent with windows
37
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
40
41 set -g set-titles on          # set terminal title
42
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
45
46 set -g status-interval 10     # redraw status line every 10 seconds
47
48 # clear both screen and history
49 bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
50
51 # activity
52 set -g monitor-activity on
53 set -g visual-activity off
54
55
56 # -- navigation ----------------------------------------------------------------
57
58 # create session
59 bind C-c new-session
60
61 # find session
62 bind C-f command-prompt -p find-session 'switch-client -t %%'
63
64 # split current window horizontally
65 bind - split-window -v
66 # split current window vertically
67 bind _ split-window -h
68
69 # pane navigation
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
76
77 # maximize current pane
78 bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane "#{session_name}" #D'
79
80 # pane resizing
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
85
86 # window navigation
87 unbind n
88 unbind p
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
92
93 # toggle mouse
94 bind m run "cut -c3- ~/.tmux.conf | sh -s _toggle_mouse"
95
96
97 # -- urlview -------------------------------------------------------------------
98
99 bind U run "cut -c3- ~/.tmux.conf | sh -s _urlview #{pane_id}"
100
101
102 # -- facebook pathpicker -------------------------------------------------------
103
104 bind F run "cut -c3- ~/.tmux.conf | sh -s _fpp #{pane_id}"
105
106
107 # -- list choice (tmux < 2.4) --------------------------------------------------
108
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'
117
118
119 # -- edit mode (tmux < 2.4) ----------------------------------------------------
120
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'
126
127
128 # -- copy mode -----------------------------------------------------------------
129
130 bind Enter copy-mode # enter copy mode
131
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'
144
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"'
154
155
156 # -- buffers -------------------------------------------------------------------
157
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
161
162
163 # -- user defined overrides ----------------------------------------------------
164
165 if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
166
167
168 # -- 8< ------------------------------------------------------------------------
169
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'
172
173
174 # EOF
175 #
176 # # exit the script if any statement returns a non-true return value
177 # set -e
178 #
179 # unset GREP_OPTIONS
180 # export LC_NUMERIC=C
181 #
182 # if ! printf '' | sed -E 's///' 2>/dev/null; then
183 #   if printf '' | sed -r 's///' 2>/dev/null; then
184 #     sed () {
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
186 #       command sed "$@"
187 #     }
188 #   fi
189 # fi
190 #
191 # __newline='
192 # '
193 #
194 # _is_enabled() {
195 #   ( ([ x"$1" = x"enabled" ] || [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ]) && return 0 ) || return 1
196 # }
197 #
198 # _circled() {
199 #   circled_digits='⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳'
200 #   if [ "$1" -le 20 ] 2>/dev/null; then
201 #     i=$(( $1 + 1 ))
202 #     eval set -- "$circled_digits"
203 #     eval echo "\${$i}"
204 #   else
205 #     echo "$1"
206 #   fi
207 # }
208 #
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
211 # }
212 #
213 # _maximize_pane() {
214 #   current_session=${1:-$(tmux display -p '#{session_name}')}
215 #   current_pane=${2:-$(tmux display -p '#{pane_id}')}
216 #
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" )
219 #
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%.*}
224 #
225 #     retry=1000
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
227 #       sleep 0.1
228 #       retry=$((retry - 1))
229 #     done
230 #     if [ "$retry" -eq 0 ]; then
231 #       tmux display 'Unable to maximize pane'
232 #     fi
233 #
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"
236 #   else
237 #     $restore || tmux kill-pane
238 #   fi
239 # }
240 #
241 # _toggle_mouse() {
242 #   old=$(tmux show -gv mouse)
243 #   new=""
244 #
245 #   if [ "$old" = "on" ]; then
246 #     new="off"
247 #   else
248 #     new="on"
249 #   fi
250 #
251 #   tmux set -g mouse $new \;\
252 #        display "mouse: $new"
253 # }
254 #
255 # _battery() {
256 #   count=0
257 #   charge=0
258 #   uname_s=$(uname -s)
259 #   case "$uname_s" in
260 #     *Darwin*)
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")
264 #         fi
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))
268 #       done  << EOF
269 # $(pmset -g batt | grep 'InternalBattery')
270 # EOF
271 #       ;;
272 #     *Linux*)
273 #       while IFS= read -r batpath; do
274 #         grep -i -q device "$batpath/scope" 2> /dev/null && continue
275 #
276 #         if [ x"$discharging" != x"true" ]; then
277 #           discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
278 #         fi
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 }')
282 #         else
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 }')
287 #           fi
288 #         fi
289 #         count=$((count + 1))
290 #       done  << EOF
291 # $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
292 # EOF
293 #       ;;
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 }')
299 #         fi
300 #         charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }')
301 #         count=$((count + 1))
302 #       done  << EOF
303 # $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining | tr -d '\r' | tail -n +2)
304 # EOF
305 #       ;;
306 #     *OpenBSD*)
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")
311 #         fi
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 }')
314 #         else
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 }')
316 #         fi
317 #         count=$((count + 1))
318 #       done
319 #       ;;
320 #   esac
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'
328 #     return
329 #   fi
330 #
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; }
341 #
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
350 #
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
355 #     else
356 #       battery_bar_length=5
357 #     fi
358 #   fi
359 #
360 #   if [ x"$discharging" = x"true" ]; then
361 #     battery_status="$battery_status_discharging"
362 #   else
363 #     battery_status="$battery_status_charging"
364 #   fi
365 #
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; }
369 #     palette_style=$1
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"
375 #
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"
378 #
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; }
393 #     battery_full_fg=$1
394 #     battery_empty_fg=$2
395 #     battery_bg=$3
396 #
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]"
408 #   fi
409 #
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; }
413 #     palette_style=$1
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"
418 #
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"
421 #
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; }
427 #
428 #     # shellcheck disable=SC2046
429 #     eval $(awk "BEGIN { printf \"battery_hbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
430 #   fi
431 #
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?}"
436 #
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; }
440 #     palette_style=$1
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"
445 #
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"
448 #
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; }
454 #
455 #     # shellcheck disable=SC2046
456 #     eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
457 #   fi
458 #
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?}"
463 #
464 #   battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
465 #
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"
471 # }
472 #
473 # _tty_info() {
474 #   tty="${1##/dev/}"
475 #   uname -s | grep -q "CYGWIN" && cygwin=true
476 #
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
481 #       }
482 #       END {
483 #         for (i in parent)
484 #         {
485 #           j = i
486 #           while (parent[j])
487 #             j = parent[j]
488 #
489 #           if (!(i in child) && j != 1)
490 #           {
491 #             file = "/proc/" i "/cmdline"; getline command < file; close(file)
492 #             gsub(/\0/, " ", command)
493 #             print i, user[i], command
494 #             exit
495 #           }
496 #         }
497 #       }
498 #     '
499 #   else
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
503 #       }
504 #       END {
505 #         for (i in parent)
506 #         {
507 #           j = i
508 #           while (parent[j])
509 #             j = parent[j]
510 #
511 #           if (!(i in child) && j != 1)
512 #           {
513 #             print i, user[i], command[i]
514 #             exit
515 #           }
516 #         }
517 #       }
518 #     '
519 #   fi
520 # }
521 #
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')
526 #   fi
527 #
528 #  printf '%s' "$args"
529 # }
530 #
531 # _username() {
532 #   tty=${1:-$(tmux display -p '#{pane_tty}')}
533 #   ssh_only=$2
534 #
535 #   tty_info=$(_tty_info "$tty")
536 #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
537 #
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 }')
544 #   else
545 #     if ! _is_enabled "$ssh_only"; then
546 #       username=$(printf '%s' "$tty_info" | cut -d' ' -f2)
547 #     fi
548 #   fi
549 #
550 #   printf '%s' "$username"
551 # }
552 #
553 # _hostname() {
554 #   tty=${1:-$(tmux display -p '#{pane_tty}')}
555 #   ssh_only=$2
556 #
557 #   tty_info=$(_tty_info "$tty")
558 #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
559 #
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 '\
568 #     { \
569 #       if ($1~/^[0-9.:]+$/) \
570 #         print $1; \
571 #       else \
572 #         split($1, a, ".") ; print a[1] \
573 #     }')
574 #   else
575 #     if ! _is_enabled "$ssh_only"; then
576 #       hostname=$(command hostname -s)
577 #     fi
578 #   fi
579 #
580 #   printf '%s' "$hostname"
581 # }
582 #
583 # _root() {
584 #   tty=${1:-$(tmux display -p '#{pane_tty}')}
585 #   username=$(_username "$tty" false)
586 #
587 #   if [ x"$username" = x"root" ]; then
588 #     tmux show -gqv '@root'
589 #   else
590 #     echo ""
591 #   fi
592 # }
593 #
594 # _uptime() {
595 #   case $(uname -s) in
596 #     *Darwin*)
597 #       boot=$(sysctl -q -n kern.boottime | awk -F'[ ,:]+' '{ print $4 }')
598 #       now=$(date +%s)
599 #       ;;
600 #     *Linux*|*CYGWIN*|*MSYS*|*MINGW*)
601 #       boot=0
602 #       now=$(cut -d' ' -f1 < /proc/uptime)
603 #       ;;
604 #     *OpenBSD*)
605 #       boot=$(sysctl -n kern.boottime)
606 #       now=$(date +%s)
607 #   esac
608 #   # shellcheck disable=SC1004
609 #   awk -v boot="$boot" -v now="$now" '
610 #     BEGIN {
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
618 #
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)
625 #     }'
626 # }
627 #
628 # _loadavg() {
629 #   case $(uname -s) in
630 #     *Darwin*)
631 #       tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f2)"
632 #       ;;
633 #     *Linux*)
634 #       tmux set -g @loadavg "$(cut -d' ' -f1 < /proc/loadavg)"
635 #       ;;
636 #     *OpenBSD*)
637 #       tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f1)"
638 #       ;;
639 #   esac
640 # }
641 #
642 # _split_window() {
643 #   tty=${1:-$(tmux display -p '#{pane_tty}')}
644 #   shift
645 #
646 #   tty_info=$(_tty_info "$tty")
647 #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
648 #
649 #   case "$command" in
650 #     *mosh-client*)
651 #       # shellcheck disable=SC2046
652 #        tmux split-window "$@" mosh $(echo "$command" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/')
653 #      ;;
654 #     *ssh*)
655 #       # shellcheck disable=SC2046
656 #       tmux split-window "$@" $(echo "$command" | sed -e 's/;/\\;/g')
657 #       ;;
658 #     *)
659 #       tmux split-window "$@"
660 #   esac
661 # }
662 #
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
666 #   case "$TERM" in
667 #     screen-*|tmux-*)
668 #       ;;
669 #     *)
670 #       tmux set-option -ga terminal-overrides ",*256col*:Tc"
671 #       ;;
672 #   esac
673 #   fi
674 # }
675 #
676 # _apply_bindings() {
677 #   cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
678 #
679 #   tmux list-keys | grep -vF 'tmux.conf.local' | grep -E '(new-window|split(-|_)window|new-session|copy-selection|copy-pipe)' > "$cfg"
680 #
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"
684 #
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
687 #     perl -p -i \
688 #       -e "s/\b(new-window)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
689 #       -e ';' \
690 #       -e "s/\bnew-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/new-window -c '#{pane_current_path}'/g" \
691 #       "$cfg"
692 #   else
693 #     perl -p -i -e "s/\bnew-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" "$cfg"
694 #   fi
695 #
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"
699 #   else
700 #     perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" "$cfg"
701 #   fi
702 #
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
706 #       perl -p -i \
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" \
708 #         -e ';' \
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" \
710 #         "$cfg"
711 #     else
712 #       perl -p -i \
713 #         -e "s/\bsplit-window\b([^;}\n]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1'/g" \
714 #         -e ';' \
715 #         -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1\"/g" \
716 #         "$cfg"
717 #     fi
718 #   else
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"
721 #     else
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"
723 #     fi
724 #   fi
725 #
726 #   tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false}
727 #   if _is_enabled "$tmux_conf_new_session_prompt"; then
728 #     perl -p -i \
729 #       -e "s/(?<!command-prompt -p )\b(new-session)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
730 #       -e ';' \
731 #       -e "s/(?<!\bcommand-prompt -p )\bnew-session\b(?! -s)/command-prompt -p new-session 'new-session -s \"%%\"'/g" \
732 #       "$cfg"
733 #   else
734 #     perl -p -i -e "s/\bcommand-prompt\s+-p\s+new-session\s+'new-session\s+-s\s+\"%%\"'/new-session/g" "$cfg"
735 #   fi
736 #
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'
744 #
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"
748 #     else
749 #       perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2/copy-selection\1/g" "$cfg"
750 #     fi
751 #   fi
752 #
753 #   # until tmux >= 3.0, output of tmux list-keys can't be consumed back by tmux source-file without applying some escapings
754 #   awk < "$cfg" \
755 #     '{i = $2 == "-T" ? 4 : 5; gsub(/^[;]$/, "\\\\&", $i); gsub(/^[$"#~]$/, "'"'"'&'"'"'", $i); gsub(/^['"'"']$/, "\"&\"", $i); print}' > "$cfg.in"
756 #
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"
763 #     done
764 #   fi
765 # }
766 #
767 # _apply_theme() {
768 #
769 #   # -- panes -------------------------------------------------------------
770 #
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
776 #
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"
780 #
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"
783 #     else
784 #       tmux setw -g window-active-style default
785 #     fi
786 #   fi
787 #
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
794 #     fat)
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}
797 #       ;;
798 #     thin|*)
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'}
801 #       ;;
802 #   esac
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"
804 #
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
807 #
808 #   tmux set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator"
809 #
810 #   # -- status line -------------------------------------------------------
811 #
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-|}")
816 #
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"
821 #
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"
826 #
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"
831 #
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"
838 #
839 #   tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-'#h ❐ #S ● #I #W'}
840 #
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")"
849 #
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'}
854 #
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"
861 #   else
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"
863 #   fi
864 #
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')
879 #
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")"
884 #
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"
889 #
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"
894 #
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"
899 #
900 #   # -- indicators
901 #
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'}
906 #
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'}
911 #
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'}
916 #
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'}
921 #
922 #   # -- status left style
923 #
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'}
928 #
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")
931 #
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")
934 #
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")
937 #
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")
940 #
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)
949 #       {
950 #         l = split(s, a, ",")
951 #         for (i = 1; i <= l; ++i)
952 #         {
953 #           o = split(a[i], _, "(") - 1
954 #           c = split(a[i], _, ")") - 1
955 #           open += o - c
956 #           o_ = split(a[i], _, "{") - 1
957 #           c_ = split(a[i], _, "}") - 1
958 #           open_ += o_ - c_
959 #           o__ = split(a[i], _, "[") - 1
960 #           c__ = split(a[i], _, "]") - 1
961 #           open__ += o__ - c__
962 #
963 #           if (i == l)
964 #             r = sprintf("%s%s", r, a[i])
965 #           else if (open || open_ || open__)
966 #             r = sprintf("%s%s,", r, a[i])
967 #           else
968 #             r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
969 #         }
970 #
971 #         gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
972 #         return r
973 #       }
974 #       BEGIN {
975 #         FS = "|"
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)
980 #       }
981 #       {
982 #         for (i = j = 1; i <= NF; ++i)
983 #         {
984 #           if (open || open_ || open__)
985 #             printf "|%s", subsplit($i)
986 #           else
987 #           {
988 #             if (i > 1)
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)
990 #             else
991 #               printf "#[fg=%s,bg=%s,%s]%s", fg[j], bg[j], attr[j], subsplit($i)
992 #           }
993 #
994 #           if (!open && !open_ && !open__)
995 #           {
996 #             j_ = j
997 #             j = j % l + 1
998 #           }
999 #         }
1000 #         printf "#[fg=%s,bg=%s,none]%s", bg[j_], "default", mainsep
1001 #       }' << EOF
1002 # $tmux_conf_theme_status_left
1003 # EOF
1004 #     )
1005 #   fi
1006 #
1007 #   status_left="$status_left "
1008 #
1009 #   # -- status right style
1010 #
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'}
1015 #
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")
1018 #
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")
1021 #
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")
1024 #
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")
1027 #
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)
1036 #       {
1037 #         l = split(s, a, ",")
1038 #         for (i = 1; i <= l; ++i)
1039 #         {
1040 #           o = split(a[i], _, "(") - 1
1041 #           c = split(a[i], _, ")") - 1
1042 #           open += o - c
1043 #           o_ = split(a[i], _, "{") - 1
1044 #           c_ = split(a[i], _, "}") - 1
1045 #           open_ += o_ - c_
1046 #           o__ = split(a[i], _, "[") - 1
1047 #           c__ = split(a[i], _, "]") - 1
1048 #           open__ += o__ - c__
1049 #
1050 #           if (i == l)
1051 #             r = sprintf("%s%s", r, a[i])
1052 #           else if (open || open_ || open__)
1053 #             r = sprintf("%s%s,", r, a[i])
1054 #           else
1055 #             r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
1056 #         }
1057 #
1058 #         gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
1059 #         return r
1060 #       }
1061 #       BEGIN {
1062 #         FS = "|"
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)
1067 #       }
1068 #       {
1069 #         for (i = j = 1; i <= NF; ++i)
1070 #         {
1071 #           if (open_ || open || open__)
1072 #             printf "|%s", subsplit($i)
1073 #           else
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)
1075 #
1076 #           if (!open && !open_ && !open__)
1077 #           {
1078 #             j_ = j
1079 #             j = j % l + 1
1080 #           }
1081 #         }
1082 #       }' << EOF
1083 # $tmux_conf_theme_status_right
1084 # EOF
1085 #     )
1086 #   fi
1087 #
1088 #   # -- variables
1089 #
1090 #   tmux set -g '@root' "$tmux_conf_theme_root"
1091 #
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
1100 #
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')
1115 #
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"
1125 #       ;;
1126 #   esac
1127 #
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')
1140 #       ;;
1141 #   esac
1142 #
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"
1160 #       ;;
1161 #   esac
1162 #
1163 #   case "$status_left $status_right" in
1164 #     *'#{loadavg}'*)
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"
1170 #       ;;
1171 #   esac
1172 #
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')
1175 #
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")"
1178 #
1179 #   # -- clock -------------------------------------------------------------
1180 #
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"
1185 # }
1186 #
1187 # _apply_configuration() {
1188 #
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'
1191 #     return
1192 #   fi
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'
1195 #     return
1196 #   fi
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'
1199 #     return
1200 #   fi
1201 #
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
1206 #       *fish)
1207 #         tmux set -g default-command "reattach-to-user-namespace -l $default_shell"
1208 #         ;;
1209 #       *sh)
1210 #         tmux set -g default-command "exec $default_shell... 2> /dev/null & reattach-to-user-namespace -l $default_shell"
1211 #         ;;
1212 #     esac
1213 #   fi
1214 #
1215 #   _apply_overrides
1216 #   _apply_bindings
1217 #   _apply_theme
1218 #   for name in $(printenv | grep -E -o '^tmux_conf_[^=]+'); do tmux setenv -gu "$name"; done;
1219 # }
1220 #
1221 # _urlview() {
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"
1224 # }
1225 #
1226 # _fpp() {
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"
1229 # }
1230 #
1231 # "$@"