Advertisement
cirrus

tmux.conf

Nov 30th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 57.40 KB | None | 0 0
  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 "tmux-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 1000                 # boost history
  25.  
  26. # edit configuration
  27. bind e new-window -n "~/.tmux.conf.local" "sh -c '\${EDITOR:-nano} ~/.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. # run-shell ~/scripts/tmux-power/tmux-power.tmux
  32. # set -g @tmux_power_theme 'moon'
  33.  
  34. # -- display -------------------------------------------------------------------
  35.  
  36. set -g base-index 1           # start windows numbering at 1
  37. setw -g pane-base-index 1     # make pane numbering consistent with windows
  38.  
  39. setw -g automatic-rename on   # rename window to reflect current program
  40. set -g renumber-windows on    # renumber windows when a window is closed
  41.  
  42. set -g set-titles on          # set terminal title
  43.  
  44. set -g display-panes-time 800 # slightly longer pane indicators display time
  45. set -g display-time 1000      # slightly longer status messages display time
  46.  
  47. set -g status-interval 10     # redraw status line every 10 seconds
  48.  
  49. # clear both screen and history
  50. bind -n C-l send-keys C-l \; run 'sleep 0.1' \; clear-history
  51.  
  52. # activity
  53. set -g monitor-activity on
  54. set -g visual-activity off
  55.  
  56.  
  57. # -- navigation ----------------------------------------------------------------
  58.  
  59. # create session
  60. bind C-c new-session
  61.  
  62. # find session
  63. bind C-f command-prompt -p find-session 'switch-client -t %%'
  64.  
  65. # split current window horizontally
  66. bind - split-window -v
  67. # split current window vertically
  68. bind _ split-window -h
  69.  
  70. # pane navigation
  71. bind -r h select-pane -L  # move left
  72. bind -r j select-pane -D  # move down
  73. bind -r k select-pane -U  # move up
  74. bind -r l select-pane -R  # move right
  75. bind > swap-pane -D       # swap current pane with the next one
  76. bind < swap-pane -U       # swap current pane with the previous one
  77.  
  78. # maximize current pane
  79. bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane "#{session_name}" #D'
  80.  
  81. # pane resizing
  82. bind -r H resize-pane -L 2
  83. bind -r J resize-pane -D 2
  84. bind -r K resize-pane -U 2
  85. bind -r L resize-pane -R 2
  86.  
  87. # window navigation
  88. unbind n
  89. unbind p
  90. bind -r C-h previous-window # select previous window
  91. bind -r C-l next-window     # select next window
  92. bind Tab last-window        # move to last active window
  93.  
  94. # toggle mouse
  95. bind m run "cut -c3- ~/.tmux.conf | sh -s _toggle_mouse"
  96. set -g @fzf-url-bind 'u'
  97.  
  98. # -- list choice (tmux < 2.4) --------------------------------------------------
  99.  
  100. # vi-choice is gone in tmux >= 2.4
  101. run -b 'tmux bind -t vi-choice h tree-collapse 2> /dev/null || true'
  102. run -b 'tmux bind -t vi-choice l tree-expand 2> /dev/null || true'
  103. run -b 'tmux bind -t vi-choice K start-of-list 2> /dev/null || true'
  104. run -b 'tmux bind -t vi-choice J end-of-list 2> /dev/null || true'
  105. run -b 'tmux bind -t vi-choice H tree-collapse-all 2> /dev/null || true'
  106. run -b 'tmux bind -t vi-choice L tree-expand-all 2> /dev/null || true'
  107. run -b 'tmux bind -t vi-choice Escape cancel 2> /dev/null || true'
  108.  
  109.  
  110. # -- edit mode (tmux < 2.4) ----------------------------------------------------
  111.  
  112. # vi-edit is gone in tmux >= 2.4
  113. run -b 'tmux bind -ct vi-edit H start-of-line 2> /dev/null || true'
  114. run -b 'tmux bind -ct vi-edit L end-of-line 2> /dev/null || true'
  115. run -b 'tmux bind -ct vi-edit q cancel 2> /dev/null || true'
  116. run -b 'tmux bind -ct vi-edit Escape cancel 2> /dev/null || true'
  117.  #statusbar & external scripts
  118. #-------------------external-scripts----------------------------------
  119.  #   run-shell ~/scripts/tmux-urlscan/urlscan.tmux
  120.  #   run-shell ~/scripts/tmux-urlview/urlview.tmux
  121.     run-shell ~/scripts/tmux-fzf-url/fzf-url.tmux
  122.     # urlview as context and url view
  123.  #   bind-key V capture-pane \; save-buffer /tmp/tmux-buffer \; \
  124.     new-window -n "urlview" '$SHELL -c "urlview  < /tmp/tmux-buffer"'
  125.  
  126.  
  127. # -- copy mode -----------------------------------------------------------------
  128.  
  129. bind Enter copy-mode # enter copy mode
  130.  
  131. run -b 'tmux bind -t vi-copy v begin-selection 2> /dev/null || true'
  132. run -b 'tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true'
  133. run -b 'tmux bind -t vi-copy C-v rectangle-toggle 2> /dev/null || true'
  134. run -b 'tmux bind -T copy-mode-vi C-v send -X rectangle-toggle 2> /dev/null || true'
  135. run -b 'tmux bind -t vi-copy y copy-selection 2> /dev/null || true'
  136. run -b 'tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true'
  137. run -b 'tmux bind -t vi-copy Escape cancel 2> /dev/null || true'
  138. run -b 'tmux bind -T copy-mode-vi Escape send -X cancel 2> /dev/null || true'
  139. run -b 'tmux bind -t vi-copy H start-of-line 2> /dev/null || true'
  140. run -b 'tmux bind -T copy-mode-vi H send -X start-of-line 2> /dev/null || true'
  141. run -b 'tmux bind -t vi-copy L end-of-line 2> /dev/null || true'
  142. run -b 'tmux bind -T copy-mode-vi L send -X end-of-line 2> /dev/null || true'
  143.  
  144. # copy to macOS clipboard
  145. if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"'
  146. if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"'
  147. # copy to X11 clipboard
  148. if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"'
  149. 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"'
  150. # copy to Windows clipboard
  151. if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"'
  152. if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"'
  153.  
  154.  
  155. # -- buffers -------------------------------------------------------------------
  156.  
  157. bind b list-buffers  # list paste buffers
  158. bind p paste-buffer  # paste from the top paste buffer
  159. bind P choose-buffer # choose which buffer to paste from
  160.  
  161.  
  162. # -- user defined overrides ----------------------------------------------------
  163.  
  164. if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
  165.  
  166.  
  167. # -- 8< ------------------------------------------------------------------------
  168.  
  169. run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
  170. 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'
  171.  
  172.  
  173. # EOF
  174. #
  175. # # exit the script if any statement returns a non-true return value
  176. # set -e
  177. #
  178. # unset GREP_OPTIONS
  179. # export LC_NUMERIC=C
  180. #
  181. # if ! printf '' | sed -E 's///' 2>/dev/null; then
  182. #   if printf '' | sed -r 's///' 2>/dev/null; then
  183. #     sed () {
  184. #       n=$#; while [ "$n" -gt 0 ]; do arg=$1; shift; case $arg in -E*) arg=-r${arg#-E};; esac; set -- "$@" "$arg"; n=$(( n - 1 )); done
  185. #       command sed "$@"
  186. #     }
  187. #   fi
  188. # fi
  189. #
  190. # __newline='
  191. # '
  192. #
  193. # _is_enabled() {
  194. #   ( ([ x"$1" = x"enabled" ] || [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ]) && return 0 ) || return 1
  195. # }
  196. #
  197. # _circled() {
  198. #   circled_digits='⓪ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳'
  199. #   if [ "$1" -le 20 ] 2>/dev/null; then
  200. #     i=$(( $1 + 1 ))
  201. #     eval set -- "$circled_digits"
  202. #     eval echo "\${$i}"
  203. #   else
  204. #     echo "$1"
  205. #   fi
  206. # }
  207. #
  208. # _decode_unicode_escapes() {
  209. #   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
  210. # }
  211. #
  212. # _maximize_pane() {
  213. #   current_session=${1:-$(tmux display -p '#{session_name}')}
  214. #   current_pane=${2:-$(tmux display -p '#{pane_id}')}
  215. #
  216. #   dead_panes=$(tmux list-panes -s -t "$current_session" -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -E -o '^1 %.+maximized.+$' || true)
  217. #   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" )
  218. #
  219. #   if [ -z "$restore" ]; then
  220. #     [ "$(tmux list-panes -t "$current_session:" | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return
  221. #     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'")
  222. #     window=${window%.*}
  223. #
  224. #     retry=1000
  225. #     while [ x"$(tmux list-panes -t "$window" -F '#{session_name}:#{window_index} #{pane_dead}' 2>/dev/null)" != x"$window 1" ] && [ "$retry" -ne 0 ]; do
  226. #       sleep 0.1
  227. #       retry=$((retry - 1))
  228. #     done
  229. #     if [ "$retry" -eq 0 ]; then
  230. #       tmux display 'Unable to maximize pane'
  231. #     fi
  232. #
  233. #     new_pane=$(tmux display -t "$window" -p '#{pane_id}')
  234. #     tmux setw -t "$window" remain-on-exit off \; swap-pane -s "$current_pane" -t "$new_pane"
  235. #   else
  236. #     $restore || tmux kill-pane
  237. #   fi
  238. # }
  239. #
  240. # _toggle_mouse() {
  241. #   old=$(tmux show -gv mouse)
  242. #   new=""
  243. #
  244. #   if [ "$old" = "on" ]; then
  245. #     new="off"
  246. #   else
  247. #     new="on"
  248. #   fi
  249. #
  250. #   tmux set -g mouse $new \;\
  251. #        display "mouse: $new"
  252. # }
  253. #
  254. # _battery() {
  255. #   count=0
  256. #   charge=0
  257. #   uname_s=$(uname -s)
  258. #   case "$uname_s" in
  259. #     *Darwin*)
  260. #       while IFS= read -r line; do
  261. #         if [ x"$discharging" != x"true" ]; then
  262. #           discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
  263. #         fi
  264. #         percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%')
  265. #         charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
  266. #         count=$((count + 1))
  267. #       done  << EOF
  268. # $(pmset -g batt | grep 'InternalBattery')
  269. # EOF
  270. #       ;;
  271. #     *Linux*)
  272. #       while IFS= read -r batpath; do
  273. #         grep -i -q device "$batpath/scope" 2> /dev/null && continue
  274. #
  275. #         if [ x"$discharging" != x"true" ]; then
  276. #           discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
  277. #         fi
  278. #         bat_capacity="$batpath/capacity"
  279. #         if [ -r "$bat_capacity" ]; then
  280. #           charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + capacity / 100 }')
  281. #         else
  282. #           bat_energy_full="$batpath/energy_full"
  283. #           bat_energy_now="$batpath/energy_now"
  284. #           if [ -r "$bat_energy_full" ] && [ -r "$bat_energy_now" ]; then
  285. #             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 }')
  286. #           fi
  287. #         fi
  288. #         count=$((count + 1))
  289. #       done  << EOF
  290. # $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
  291. # EOF
  292. #       ;;
  293. #     *CYGWIN*|*MSYS*|*MINGW*)
  294. #       while IFS= read -r line; do
  295. #         [ -z "$line" ] && continue
  296. #         if [ x"$discharging" != x"true" ]; then
  297. #           discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
  298. #         fi
  299. #         charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }')
  300. #         count=$((count + 1))
  301. #       done  << EOF
  302. # $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining | tr -d '\r' | tail -n +2)
  303. # EOF
  304. #       ;;
  305. #     *OpenBSD*)
  306. #       for batid in 0 1 2; do
  307. #         sysctl -n "hw.sensors.acpibat$batid.raw0" 2>&1 | grep -q 'not found' && continue
  308. #         if [ x"$discharging" != x"true" ]; then
  309. #           discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
  310. #         fi
  311. #         if sysctl -n "hw.sensors.acpibat$batid" | grep -q amphour; then
  312. #           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 }')
  313. #         else
  314. #           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 }')
  315. #         fi
  316. #         count=$((count + 1))
  317. #       done
  318. #       ;;
  319. #   esac
  320. #   [ "$count" -ne 0 ] && charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }')
  321. #   if [ "$charge" -eq 0 ]; then
  322. #     tmux  set -ug '@battery_status'  \;\
  323. #           set -ug '@battery_bar'     \;\
  324. #           set -ug '@battery_hbar'    \;\
  325. #           set -ug '@battery_vbar'    \;\
  326. #           set -ug '@battery_percentage'
  327. #     return
  328. #   fi
  329. #
  330. #   variables=$(tmux  show -gqv '@battery_bar_symbol_full' \;\
  331. #                     show -gqv '@battery_bar_symbol_empty' \;\
  332. #                     show -gqv '@battery_bar_length' \;\
  333. #                     show -gqv '@battery_bar_palette' \;\
  334. #                     show -gqv '@battery_hbar_palette' \;\
  335. #                     show -gqv '@battery_vbar_palette' \;\
  336. #                     show -gqv '@battery_status_charging' \;\
  337. #                     show -gqv '@battery_status_discharging')
  338. #   # shellcheck disable=SC2086
  339. #   { set -f; IFS="$__newline"; set -- $variables; unset IFS; set +f; }
  340. #
  341. #   battery_bar_symbol_full=$1
  342. #   battery_bar_symbol_empty=$2
  343. #   battery_bar_length=$3
  344. #   battery_bar_palette=$4
  345. #   battery_hbar_palette=$5
  346. #   battery_vbar_palette=$6
  347. #   battery_status_charging=$7
  348. #   battery_status_discharging=$8
  349. #
  350. #   if [ x"$battery_bar_length" = x"auto" ]; then
  351. #     columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)
  352. #     if [ "$columns" -ge 80 ]; then
  353. #       battery_bar_length=10
  354. #     else
  355. #       battery_bar_length=5
  356. #     fi
  357. #   fi
  358. #
  359. #   if [ x"$discharging" = x"true" ]; then
  360. #     battery_status="$battery_status_discharging"
  361. #   else
  362. #     battery_status="$battery_status_charging"
  363. #   fi
  364. #
  365. #   if echo "$battery_bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
  366. #     # shellcheck disable=SC2086
  367. #     { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
  368. #     palette_style=$1
  369. #     battery_bg=${2:-none}
  370. #     [ x"$palette_style" = x"gradient" ] && \
  371. #       palette="196 202 208 214 220 226 190 154 118 82 46"
  372. #     [ x"$palette_style" = x"heat" ] && \
  373. #       palette="243 245 247 144 143 142 184 214 208 202 196"
  374. #
  375. #     palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
  376. #     eval set -- "$palette"
  377. #
  378. #     full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
  379. #     battery_bar="#[bg=$battery_bg]"
  380. #     # shellcheck disable=SC2046
  381. #     [ "$full" -gt 0 ] && \
  382. #       battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
  383. #     # shellcheck disable=SC2046
  384. #     empty=$((battery_bar_length - full))
  385. #     # shellcheck disable=SC2046
  386. #     [ "$empty" -gt 0 ] && \
  387. #       battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
  388. #       eval battery_bar="$battery_bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
  389. #   elif echo "$battery_bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
  390. #     # shellcheck disable=SC2086
  391. #     { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
  392. #     battery_full_fg=$1
  393. #     battery_empty_fg=$2
  394. #     battery_bg=$3
  395. #
  396. #     full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
  397. #     [ x"$battery_bg" != x"none" ] && \
  398. #       battery_bar="#[bg=$battery_bg]"
  399. #     #shellcheck disable=SC2046
  400. #     [ "$full" -gt 0 ] && \
  401. #       battery_bar="$battery_bar#[fg=$battery_full_fg]$(printf "%0.s$battery_bar_symbol_full" $(seq 1 "$full"))"
  402. #     empty=$((battery_bar_length - full))
  403. #     #shellcheck disable=SC2046
  404. #     [ "$empty" -gt 0 ] && \
  405. #       battery_bar="$battery_bar#[fg=$battery_empty_fg]$(printf "%0.s$battery_bar_symbol_empty" $(seq 1 "$empty"))" && \
  406. #       battery_bar="$battery_bar#[fg=$battery_empty_fg]"
  407. #   fi
  408. #
  409. #   if echo "$battery_hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
  410. #     # shellcheck disable=SC2086
  411. #     { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
  412. #     palette_style=$1
  413. #     [ x"$palette_style" = x"gradient" ] && \
  414. #       palette="196 202 208 214 220 226 190 154 118 82 46"
  415. #     [ x"$palette_style" = x"heat" ] && \
  416. #       palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
  417. #
  418. #     palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
  419. #     eval set -- "$palette"
  420. #
  421. #     full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
  422. #     eval battery_hbar_fg="colour\${$((full == 0 ? 1 : full))}"
  423. #   elif echo "$battery_hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
  424. #     # shellcheck disable=SC2086
  425. #     { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
  426. #
  427. #     # shellcheck disable=SC2046
  428. #     eval $(awk "BEGIN { printf \"battery_hbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
  429. #   fi
  430. #
  431. #   eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
  432. #   # shellcheck disable=SC2046
  433. #   eval $(awk "BEGIN { printf \"battery_hbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
  434. #   battery_hbar="#[fg=${battery_hbar_fg?}]${battery_hbar_symbol?}"
  435. #
  436. #   if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
  437. #     # shellcheck disable=SC2086
  438. #     { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
  439. #     palette_style=$1
  440. #     [ x"$palette_style" = x"gradient" ] && \
  441. #       palette="196 202 208 214 220 226 190 154 118 82 46"
  442. #     [ x"$palette_style" = x"heat" ] && \
  443. #       palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
  444. #
  445. #     palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
  446. #     eval set -- "$palette"
  447. #
  448. #     full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
  449. #     eval battery_vbar_fg="colour\${$((full == 0 ? 1 : full))}"
  450. #   elif echo "$battery_vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
  451. #     # shellcheck disable=SC2086
  452. #     { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
  453. #
  454. #     # shellcheck disable=SC2046
  455. #     eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
  456. #   fi
  457. #
  458. #   eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
  459. #   # shellcheck disable=SC2046
  460. #   eval $(awk "BEGIN { printf \"battery_vbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
  461. #   battery_vbar="#[fg=${battery_vbar_fg?}]${battery_vbar_symbol?}"
  462. #
  463. #   battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
  464. #
  465. #   tmux  set -g '@battery_status' "$battery_status" \;\
  466. #         set -g '@battery_bar' "$battery_bar" \;\
  467. #         set -g '@battery_hbar' "$battery_hbar" \;\
  468. #         set -g '@battery_vbar' "$battery_vbar" \;\
  469. #         set -g '@battery_percentage' "$battery_percentage"
  470. # }
  471. #
  472. # _tty_info() {
  473. #   tty="${1##/dev/}"
  474. #   uname -s | grep -q "CYGWIN" && cygwin=true
  475. #
  476. #   if [ x"$cygwin" = x"true" ]; then
  477. #     ps -af | tail -n +2 | awk -v tty="$tty" '
  478. #       ((/ssh/ && !/-W/) || !/ssh/) && $4 == tty {
  479. #         user[$2] = $1; parent[$2] = $3; child[$3] = $2
  480. #       }
  481. #       END {
  482. #         for (i in parent)
  483. #         {
  484. #           j = i
  485. #           while (parent[j])
  486. #             j = parent[j]
  487. #
  488. #           if (!(i in child) && j != 1)
  489. #           {
  490. #             file = "/proc/" i "/cmdline"; getline command < file; close(file)
  491. #             gsub(/\0/, " ", command)
  492. #             print i, user[i], command
  493. #             exit
  494. #           }
  495. #         }
  496. #       }
  497. #     '
  498. #   else
  499. #     ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk '
  500. #       NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) {
  501. #         user[$2] = $1; parent[$2] = $3; child[$3] = $2; for (i = 4 ; i <= NF; ++i) command[$2] = i > 4 ? command[$2] FS $i : $i
  502. #       }
  503. #       END {
  504. #         for (i in parent)
  505. #         {
  506. #           j = i
  507. #           while (parent[j])
  508. #             j = parent[j]
  509. #
  510. #           if (!(i in child) && j != 1)
  511. #           {
  512. #             print i, user[i], command[i]
  513. #             exit
  514. #           }
  515. #         }
  516. #       }
  517. #     '
  518. #   fi
  519. # }
  520. #
  521. # _ssh_or_mosh_args() {
  522. #   args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1=""; print $0; exit }')
  523. #   if [ -z "$args" ]; then
  524. #     args=$(printf '%s' "$1" | grep 'mosh-client' | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g')
  525. #   fi
  526. #
  527. #  printf '%s' "$args"
  528. # }
  529. #
  530. # _username() {
  531. #   tty=${1:-$(tmux display -p '#{pane_tty}')}
  532. #   ssh_only=$2
  533. #
  534. #   tty_info=$(_tty_info "$tty")
  535. #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
  536. #
  537. #   ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
  538. #   if [ -n "$ssh_or_mosh_args" ]; then
  539. #     # shellcheck disable=SC2086
  540. #     username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^user / { print $2 }')
  541. #     # shellcheck disable=SC2086
  542. #     [ -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 }')
  543. #   else
  544. #     if ! _is_enabled "$ssh_only"; then
  545. #       username=$(printf '%s' "$tty_info" | cut -d' ' -f2)
  546. #     fi
  547. #   fi
  548. #
  549. #   printf '%s' "$username"
  550. # }
  551. #
  552. # _hostname() {
  553. #   tty=${1:-$(tmux display -p '#{pane_tty}')}
  554. #   ssh_only=$2
  555. #
  556. #   tty_info=$(_tty_info "$tty")
  557. #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
  558. #
  559. #   ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
  560. #   if [ -n "$ssh_or_mosh_args" ]; then
  561. #     # shellcheck disable=SC2086
  562. #     hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk 'NR > 2 { exit } ; /^hostname / { print $2 }')
  563. #     # shellcheck disable=SC2086
  564. #     [ -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 }')
  565. #     #shellcheck disable=SC1004
  566. #     hostname=$(echo "$hostname" | awk '\
  567. #     { \
  568. #       if ($1~/^[0-9.:]+$/) \
  569. #         print $1; \
  570. #       else \
  571. #         split($1, a, ".") ; print a[1] \
  572. #     }')
  573. #   else
  574. #     if ! _is_enabled "$ssh_only"; then
  575. #       hostname=$(command hostname -s)
  576. #     fi
  577. #   fi
  578. #
  579. #   printf '%s' "$hostname"
  580. # }
  581. #
  582. # _root() {
  583. #   tty=${1:-$(tmux display -p '#{pane_tty}')}
  584. #   username=$(_username "$tty" false)
  585. #
  586. #   if [ x"$username" = x"root" ]; then
  587. #     tmux show -gqv '@root'
  588. #   else
  589. #     echo ""
  590. #   fi
  591. # }
  592. #
  593. # _uptime() {
  594. #   case $(uname -s) in
  595. #     *Darwin*)
  596. #       boot=$(sysctl -q -n kern.boottime | awk -F'[ ,:]+' '{ print $4 }')
  597. #       now=$(date +%s)
  598. #       ;;
  599. #     *Linux*|*CYGWIN*|*MSYS*|*MINGW*)
  600. #       boot=0
  601. #       now=$(cut -d' ' -f1 < /proc/uptime)
  602. #       ;;
  603. #     *OpenBSD*)
  604. #       boot=$(sysctl -n kern.boottime)
  605. #       now=$(date +%s)
  606. #   esac
  607. #   # shellcheck disable=SC1004
  608. #   awk -v boot="$boot" -v now="$now" '
  609. #     BEGIN {
  610. #       uptime = now - boot
  611. #       y = int(uptime / 31536000)
  612. #       dy = int(uptime / 86400) % 365
  613. #       d = int(uptime / 86400)
  614. #       h = int(uptime / 3600) % 24
  615. #       m = int(uptime / 60) % 60
  616. #       s = int(uptime) % 60
  617. #
  618. #       system("tmux  set -g @uptime_y " y + 0 " \\; " \
  619. #                    "set -g @uptime_dy " dy + 0 " \\; " \
  620. #                    "set -g @uptime_d " d + 0 " \\; " \
  621. #                    "set -g @uptime_h " h + 0 " \\; " \
  622. #                    "set -g @uptime_m " m + 0 " \\; " \
  623. #                    "set -g @uptime_s " s + 0)
  624. #     }'
  625. # }
  626. #
  627. # _loadavg() {
  628. #   case $(uname -s) in
  629. #     *Darwin*)
  630. #       tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f2)"
  631. #       ;;
  632. #     *Linux*)
  633. #       tmux set -g @loadavg "$(cut -d' ' -f1 < /proc/loadavg)"
  634. #       ;;
  635. #     *OpenBSD*)
  636. #       tmux set -g @loadavg "$(sysctl -q -n vm.loadavg | cut -d' ' -f1)"
  637. #       ;;
  638. #   esac
  639. # }
  640. #
  641. # _split_window() {
  642. #   tty=${1:-$(tmux display -p '#{pane_tty}')}
  643. #   shift
  644. #
  645. #   tty_info=$(_tty_info "$tty")
  646. #   command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
  647. #
  648. #   case "$command" in
  649. #     *mosh-client*)
  650. #       # shellcheck disable=SC2046
  651. #        tmux split-window "$@" mosh $(echo "$command" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/')
  652. #      ;;
  653. #     *ssh*)
  654. #       # shellcheck disable=SC2046
  655. #       tmux split-window "$@" $(echo "$command" | sed -e 's/;/\\;/g')
  656. #       ;;
  657. #     *)
  658. #       tmux split-window "$@"
  659. #   esac
  660. # }
  661. #
  662. # _apply_overrides() {
  663. #   tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-false}
  664. #   if _is_enabled "$tmux_conf_theme_24b_colour"; then
  665. #   case "$TERM" in
  666. #     screen-*|tmux-*)
  667. #       ;;
  668. #     *)
  669. #       tmux set-option -ga terminal-overrides ",*256col*:Tc"
  670. #       ;;
  671. #   esac
  672. #   fi
  673. # }
  674. #
  675. # _apply_bindings() {
  676. #   cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
  677. #
  678. #   tmux list-keys | grep -vF 'tmux.conf.local' | grep -E '(new-window|split(-|_)window|new-session|copy-selection|copy-pipe)' > "$cfg"
  679. #
  680. #   # tmux 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the
  681. #   # output of list-keys can be truncated
  682. #   perl -p -i -e "s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}\"/g" "$cfg"
  683. #
  684. #   tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false}
  685. #   if _is_enabled "$tmux_conf_new_window_retain_current_path"; then
  686. #     perl -p -i \
  687. #       -e "s/\b(new-window)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
  688. #       -e ';' \
  689. #       -e "s/\bnew-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/new-window -c '#{pane_current_path}'/g" \
  690. #       "$cfg"
  691. #   else
  692. #     perl -p -i -e "s/\bnew-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" "$cfg"
  693. #   fi
  694. #
  695. #   tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-false}
  696. #   if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
  697. #     perl -p -i -e "s/\bsplit-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/split-window -c '#{pane_current_path}'/g" "$cfg"
  698. #   else
  699. #     perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" "$cfg"
  700. #   fi
  701. #
  702. #   tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false}
  703. #   if _is_enabled "$tmux_conf_new_pane_reconnect_ssh"; then
  704. #     if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
  705. #       perl -p -i \
  706. #         -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" \
  707. #         -e ';' \
  708. #         -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" \
  709. #         "$cfg"
  710. #     else
  711. #       perl -p -i \
  712. #         -e "s/\bsplit-window\b([^;}\n]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1'/g" \
  713. #         -e ';' \
  714. #         -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1\"/g" \
  715. #         "$cfg"
  716. #     fi
  717. #   else
  718. #     if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
  719. #       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"
  720. #     else
  721. #       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"
  722. #     fi
  723. #   fi
  724. #
  725. #   tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false}
  726. #   if _is_enabled "$tmux_conf_new_session_prompt"; then
  727. #     perl -p -i \
  728. #       -e "s/(?<!command-prompt -p )\b(new-session)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
  729. #       -e ';' \
  730. #       -e "s/(?<!\bcommand-prompt -p )\bnew-session\b(?! -s)/command-prompt -p new-session 'new-session -s \"%%\"'/g" \
  731. #       "$cfg"
  732. #   else
  733. #     perl -p -i -e "s/\bcommand-prompt\s+-p\s+new-session\s+'new-session\s+-s\s+\"%%\"'/new-session/g" "$cfg"
  734. #   fi
  735. #
  736. #   tmux_conf_copy_to_os_clipboard=${tmux_conf_copy_to_os_clipboard:-false}
  737. #   command -v pbcopy > /dev/null 2>&1 && command='pbcopy'
  738. #   command -v reattach-to-user-namespace > /dev/null 2>&1 && command='reattach-to-user-namespace pbcopy'
  739. #   command -v xsel > /dev/null 2>&1 && command='xsel -i -b'
  740. #   ! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1 && command='xclip -i -selection clipboard > \/dev\/null 2>\&1'
  741. #   command -v clip.exe > /dev/null 2>&1 && command='clip\.exe'
  742. #   [ -c /dev/clipboard ] && command='cat > \/dev\/clipboard'
  743. #
  744. #   if [ -n "$command" ]; then
  745. #     if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then
  746. #       perl -p -i -e "s/\bcopy-selection(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg"
  747. #     else
  748. #       perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2/copy-selection\1/g" "$cfg"
  749. #     fi
  750. #   fi
  751. #
  752. #   # until tmux >= 3.0, output of tmux list-keys can't be consumed back by tmux source-file without applying some escapings
  753. #   awk < "$cfg" \
  754. #     '{i = $2 == "-T" ? 4 : 5; gsub(/^[;]$/, "\\\\&", $i); gsub(/^[$"#~]$/, "'"'"'&'"'"'", $i); gsub(/^['"'"']$/, "\"&\"", $i); print}' > "$cfg.in"
  755. #
  756. #   # ignore bindings with errors
  757. #   if ! tmux source-file "$cfg.in"; then
  758. #     verbose_flag=$(tmux source-file -v /dev/null 2> /dev/null && printf -- '-v' || true)
  759. #     while ! out=$(tmux source-file "$verbose_flag" "$cfg.in"); do
  760. #       line=$(printf "%s" "$out" | tail -1 | cut -d':' -f2)
  761. #       perl -n -i -e "if ($. != $line) { print }" "$cfg.in"
  762. #     done
  763. #   fi
  764. # }
  765. #
  766. # _apply_theme() {
  767. #
  768. #   # -- panes -------------------------------------------------------------
  769. #
  770. #   tmux_conf_theme_window_fg=${tmux_conf_theme_window_fg:-default}
  771. #   tmux_conf_theme_window_bg=${tmux_conf_theme_window_bg:-default}
  772. #   tmux_conf_theme_highlight_focused_pane=${tmux_conf_theme_highlight_focused_pane:-false}
  773. #   tmux_conf_theme_focused_pane_fg=${tmux_conf_theme_focused_pane_fg:-'default'} # default
  774. #   tmux_conf_theme_focused_pane_bg=${tmux_conf_theme_focused_pane_bg:-'#0087d7'} # light blue
  775. #
  776. #   # tmux 1.9 doesn't really like set -q
  777. #   if tmux show -g -w | grep -q window-style; then
  778. #     tmux setw -g window-style "fg=$tmux_conf_theme_window_fg,bg=$tmux_conf_theme_window_bg"
  779. #
  780. #     if _is_enabled "$tmux_conf_theme_highlight_focused_pane"; then
  781. #       tmux setw -g window-active-style "fg=$tmux_conf_theme_focused_pane_fg,bg=$tmux_conf_theme_focused_pane_bg"
  782. #     else
  783. #       tmux setw -g window-active-style default
  784. #     fi
  785. #   fi
  786. #
  787. #   tmux_conf_theme_pane_border_style=${tmux_conf_theme_pane_border_style:-thin}
  788. #   tmux_conf_theme_pane_border=${tmux_conf_theme_pane_border:-'#444444'}               # light gray
  789. #   tmux_conf_theme_pane_active_border=${tmux_conf_theme_pane_active_border:-'#00afff'} # light blue
  790. #   tmux_conf_theme_pane_border_fg=${tmux_conf_theme_pane_border_fg:-$tmux_conf_theme_pane_border}
  791. #   tmux_conf_theme_pane_active_border_fg=${tmux_conf_theme_pane_active_border_fg:-$tmux_conf_theme_pane_active_border}
  792. #   case "$tmux_conf_theme_pane_border_style" in
  793. #     fat)
  794. #       tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-$tmux_conf_theme_pane_border_fg}
  795. #       tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-$tmux_conf_theme_pane_active_border_fg}
  796. #       ;;
  797. #     thin|*)
  798. #       tmux_conf_theme_pane_border_bg=${tmux_conf_theme_pane_border_bg:-'default'}
  799. #       tmux_conf_theme_pane_active_border_bg=${tmux_conf_theme_pane_active_border_bg:-'default'}
  800. #       ;;
  801. #   esac
  802. #   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"
  803. #
  804. #   tmux_conf_theme_pane_indicator=${tmux_conf_theme_pane_indicator:-'#00afff'}               # light blue
  805. #   tmux_conf_theme_pane_active_indicator=${tmux_conf_theme_pane_active_indicator:-'#00afff'} # light blue
  806. #
  807. #   tmux set -g display-panes-colour "$tmux_conf_theme_pane_indicator" \; set -g display-panes-active-colour "$tmux_conf_theme_pane_active_indicator"
  808. #
  809. #   # -- status line -------------------------------------------------------
  810. #
  811. #   tmux_conf_theme_left_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_main-}")
  812. #   tmux_conf_theme_left_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_sub-|}")
  813. #   tmux_conf_theme_right_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_main-}")
  814. #   tmux_conf_theme_right_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_sub-|}")
  815. #
  816. #   tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-'#000000'}   # black
  817. #   tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-'#ffff00'}   # yellow
  818. #   tmux_conf_theme_message_attr=${tmux_conf_theme_message_attr:-'bold'}
  819. #   tmux set -g message-style "fg=$tmux_conf_theme_message_fg,bg=$tmux_conf_theme_message_bg,$tmux_conf_theme_message_attr"
  820. #
  821. #   tmux_conf_theme_message_command_fg=${tmux_conf_theme_message_command_fg:-'#ffff00'} # yellow
  822. #   tmux_conf_theme_message_command_bg=${tmux_conf_theme_message_command_bg:-'#000000'} # black
  823. #   tmux_conf_theme_message_command_attr=${tmux_conf_theme_message_command_attr:-'bold'}
  824. #   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"
  825. #
  826. #   tmux_conf_theme_mode_fg=${tmux_conf_theme_mode_fg:-'#000000'} # black
  827. #   tmux_conf_theme_mode_bg=${tmux_conf_theme_mode_bg:-'#ffff00'} # yellow
  828. #   tmux_conf_theme_mode_attr=${tmux_conf_theme_mode_attr:-'bold'}
  829. #   tmux setw -g mode-style "fg=$tmux_conf_theme_mode_fg,bg=$tmux_conf_theme_mode_bg,$tmux_conf_theme_mode_attr"
  830. #
  831. #   tmux_conf_theme_status_fg=${tmux_conf_theme_status_fg:-'#8a8a8a'} # white
  832. #   tmux_conf_theme_status_bg=${tmux_conf_theme_status_bg:-'#080808'} # dark gray
  833. #   tmux_conf_theme_status_attr=${tmux_conf_theme_status_attr:-'none'}
  834. #   tmux  set -g status-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr"        \;\
  835. #         set -g status-left-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr"   \;\
  836. #         set -g status-right-style "fg=$tmux_conf_theme_status_fg,bg=$tmux_conf_theme_status_bg,$tmux_conf_theme_status_attr"
  837. #
  838. #   tmux_conf_theme_terminal_title=${tmux_conf_theme_terminal_title:-'#h ❐ #S ●  #W'}
  839. #
  840. #   tmux_conf_theme_terminal_title=$(echo "$tmux_conf_theme_terminal_title" | sed \
  841. #     -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
  842. #     -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
  843. #     -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
  844. #     -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
  845. #     -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
  846. #     -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
  847. #   tmux set -g set-titles-string "$(_decode_unicode_escapes "$tmux_conf_theme_terminal_title")"
  848. #
  849. #   tmux_conf_theme_window_status_fg=${tmux_conf_theme_window_status_fg:-'#8a8a8a'} # white
  850. #   tmux_conf_theme_window_status_bg=${tmux_conf_theme_window_status_bg:-'#080808'} # dark gray
  851. #   tmux_conf_theme_window_status_attr=${tmux_conf_theme_window_status_attr:-'none'}
  852. #   tmux_conf_theme_window_status_format=${tmux_conf_theme_window_status_format:-'#W'}
  853. #
  854. #   tmux_conf_theme_window_status_current_fg=${tmux_conf_theme_window_status_current_fg:-'#000000'} # black
  855. #   tmux_conf_theme_window_status_current_bg=${tmux_conf_theme_window_status_current_bg:-'#00afff'} # light blue
  856. #   tmux_conf_theme_window_status_current_attr=${tmux_conf_theme_window_status_current_attr:-'bold'}
  857. #   tmux_conf_theme_window_status_current_format=${tmux_conf_theme_window_status_current_format:-'#W'}
  858. #   if [ x"$(tmux show -g -v status-justify)" = x"right" ]; then
  859. #     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"
  860. #   else
  861. #     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"
  862. #   fi
  863. #
  864. #   tmux_conf_theme_window_status_format=$(echo "$tmux_conf_theme_window_status_format" | sed \
  865. #     -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
  866. #     -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
  867. #     -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
  868. #     -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
  869. #     -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
  870. #     -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
  871. #   tmux_conf_theme_window_status_current_format=$(echo "$tmux_conf_theme_window_status_current_format" | sed \
  872. #     -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \
  873. #     -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \
  874. #     -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
  875. #     -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
  876. #     -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
  877. #     -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
  878. #
  879. #   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" \;\
  880. #         setw -g window-status-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_format")" \;\
  881. #         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" \;\
  882. #         setw -g window-status-current-format "$(_decode_unicode_escapes "$tmux_conf_theme_window_status_current_format")"
  883. #
  884. #   tmux_conf_theme_window_status_activity_fg=${tmux_conf_theme_window_status_activity_fg:-'default'}
  885. #   tmux_conf_theme_window_status_activity_bg=${tmux_conf_theme_window_status_activity_bg:-'default'}
  886. #   tmux_conf_theme_window_status_activity_attr=${tmux_conf_theme_window_status_activity_attr:-'underscore'}
  887. #   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"
  888. #
  889. #   tmux_conf_theme_window_status_bell_fg=${tmux_conf_theme_window_status_bell_fg:-'#ffff00'} # yellow
  890. #   tmux_conf_theme_window_status_bell_bg=${tmux_conf_theme_window_status_bell_bg:-'default'}
  891. #   tmux_conf_theme_window_status_bell_attr=${tmux_conf_theme_window_status_bell_attr:-'blink,bold'}
  892. #   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"
  893. #
  894. #   tmux_conf_theme_window_status_last_fg=${tmux_conf_theme_window_status_last_fg:-'#00afff'} # light blue
  895. #   tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-'default'}
  896. #   tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-'none'}
  897. #   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"
  898. #
  899. #   # -- indicators
  900. #
  901. #   tmux_conf_theme_pairing=${tmux_conf_theme_pairing:-'👓'}            # U+1F453
  902. #   tmux_conf_theme_pairing_fg=${tmux_conf_theme_pairing_fg:-'#e4e4e4'} # white
  903. #   tmux_conf_theme_pairing_bg=${tmux_conf_theme_pairing_bg:-'none'}
  904. #   tmux_conf_theme_pairing_attr=${tmux_conf_theme_pairing_attr:-'none'}
  905. #
  906. #   tmux_conf_theme_prefix=${tmux_conf_theme_prefix:-'⌨'}             # U+2328
  907. #   tmux_conf_theme_prefix_fg=${tmux_conf_theme_prefix_fg:-'#e4e4e4'} # white
  908. #   tmux_conf_theme_prefix_bg=${tmux_conf_theme_prefix_bg:-'none'}
  909. #   tmux_conf_theme_prefix_attr=${tmux_conf_theme_prefix_attr:-'none'}
  910. #
  911. #   tmux_conf_theme_root=${tmux_conf_theme_root:-'!'}
  912. #   tmux_conf_theme_root_fg=${tmux_conf_theme_root_fg:-'none'}
  913. #   tmux_conf_theme_root_bg=${tmux_conf_theme_root_bg:-'none'}
  914. #   tmux_conf_theme_root_attr=${tmux_conf_theme_root_attr:-'bold,blink'}
  915. #
  916. #   tmux_conf_theme_synchronized=${tmux_conf_theme_synchronized:-'🔒'}  # U+1F512
  917. #   tmux_conf_theme_synchronized_fg=${tmux_conf_theme_synchronized_fg:-'none'}
  918. #   tmux_conf_theme_synchronized_bg=${tmux_conf_theme_synchronized_bg:-'none'}
  919. #   tmux_conf_theme_synchronized_attr=${tmux_conf_theme_synchronized_attr:-'none'}
  920. #
  921. #   # -- status left style
  922. #
  923. #   tmux_conf_theme_status_left=${tmux_conf_theme_status_left-' ❐ #S '}
  924. #   tmux_conf_theme_status_left_fg=${tmux_conf_theme_status_left_fg:-'#000000,#e4e4e4,#e4e4e4'}  # black, white , white
  925. #   tmux_conf_theme_status_left_bg=${tmux_conf_theme_status_left_bg:-'#ffff00,#ff00af,#00afff'}  # yellow, pink, white blue
  926. #   tmux_conf_theme_status_left_attr=${tmux_conf_theme_status_left_attr:-'bold,none,none'}
  927. #
  928. #   tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
  929. #     -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")
  930. #
  931. #   tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
  932. #     -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")
  933. #
  934. #   tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
  935. #     -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")
  936. #
  937. #   tmux_conf_theme_status_left=$(echo "$tmux_conf_theme_status_left" | sed \
  938. #     -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")
  939. #
  940. #   if [ -n "$tmux_conf_theme_status_left" ]; then
  941. #     status_left=$(awk \
  942. #                       -v fg_="$tmux_conf_theme_status_left_fg" \
  943. #                       -v bg_="$tmux_conf_theme_status_left_bg" \
  944. #                       -v attr_="$tmux_conf_theme_status_left_attr" \
  945. #                       -v mainsep="$tmux_conf_theme_left_separator_main" \
  946. #                       -v subsep="$tmux_conf_theme_left_separator_sub" '
  947. #       function subsplit(s,   l, i, a, r)
  948. #       {
  949. #         l = split(s, a, ",")
  950. #         for (i = 1; i <= l; ++i)
  951. #         {
  952. #           o = split(a[i], _, "(") - 1
  953. #           c = split(a[i], _, ")") - 1
  954. #           open += o - c
  955. #           o_ = split(a[i], _, "{") - 1
  956. #           c_ = split(a[i], _, "}") - 1
  957. #           open_ += o_ - c_
  958. #           o__ = split(a[i], _, "[") - 1
  959. #           c__ = split(a[i], _, "]") - 1
  960. #           open__ += o__ - c__
  961. #
  962. #           if (i == l)
  963. #             r = sprintf("%s%s", r, a[i])
  964. #           else if (open || open_ || open__)
  965. #             r = sprintf("%s%s,", r, a[i])
  966. #           else
  967. #             r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
  968. #         }
  969. #
  970. #         gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
  971. #         return r
  972. #       }
  973. #       BEGIN {
  974. #         FS = "|"
  975. #         l1 = split(fg_, fg, ",")
  976. #         l2 = split(bg_, bg, ",")
  977. #         l3 = split(attr_, attr, ",")
  978. #         l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3)
  979. #       }
  980. #       {
  981. #         for (i = j = 1; i <= NF; ++i)
  982. #         {
  983. #           if (open || open_ || open__)
  984. #             printf "|%s", subsplit($i)
  985. #           else
  986. #           {
  987. #             if (i > 1)
  988. #               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)
  989. #             else
  990. #               printf "#[fg=%s,bg=%s,%s]%s", fg[j], bg[j], attr[j], subsplit($i)
  991. #           }
  992. #
  993. #           if (!open && !open_ && !open__)
  994. #           {
  995. #             j_ = j
  996. #             j = j % l + 1
  997. #           }
  998. #         }
  999. #         printf "#[fg=%s,bg=%s,none]%s", bg[j_], "default", mainsep
  1000. #       }' << EOF
  1001. # $tmux_conf_theme_status_left
  1002. # EOF
  1003. #     )
  1004. #   fi
  1005. #
  1006. #   status_left="$status_left "
  1007. #
  1008. #   # -- status right style
  1009. #
  1010. #   tmux_conf_theme_status_right=${tmux_conf_theme_status_right-'#{pairing}#{prefix} #{battery_status} #{battery_bar} #{battery_percentage} , %R , %d %b | #{username} | #{hostname} '}
  1011. #   tmux_conf_theme_status_right_fg=${tmux_conf_theme_status_right_fg:-'#8a8a8a,#e4e4e4,#000000'} # light gray, white, black
  1012. #   tmux_conf_theme_status_right_bg=${tmux_conf_theme_status_right_bg:-'#080808,#d70000,#e4e4e4'} # dark gray, red, white
  1013. #   tmux_conf_theme_status_right_attr=${tmux_conf_theme_status_right_attr:-'none,none,bold'}
  1014. #
  1015. #   tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
  1016. #     -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")
  1017. #
  1018. #   tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
  1019. #     -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")
  1020. #
  1021. #   tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
  1022. #     -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")
  1023. #
  1024. #   tmux_conf_theme_status_right=$(echo "$tmux_conf_theme_status_right" | sed \
  1025. #     -e "s%#{synchronized}%#[fg=$tmux_conf_theme_synchronized_fg]#[bg=$tmux_conf_theme_synchronized_bg]#[$tmux_conf_theme_synchronized_attr]#{?pane_synchronized,$tmux_conf_theme_synchronized,}%g")
  1026. #
  1027. #   if [ -n "$tmux_conf_theme_status_right" ]; then
  1028. #     status_right=$(awk \
  1029. #                       -v fg_="$tmux_conf_theme_status_right_fg" \
  1030. #                       -v bg_="$tmux_conf_theme_status_right_bg" \
  1031. #                       -v attr_="$tmux_conf_theme_status_right_attr" \
  1032. #                       -v mainsep="$tmux_conf_theme_right_separator_main" \
  1033. #                       -v subsep="$tmux_conf_theme_right_separator_sub" '
  1034. #       function subsplit(s,   l, i, a, r)
  1035. #       {
  1036. #         l = split(s, a, ",")
  1037. #         for (i = 1; i <= l; ++i)
  1038. #         {
  1039. #           o = split(a[i], _, "(") - 1
  1040. #           c = split(a[i], _, ")") - 1
  1041. #           open += o - c
  1042. #           o_ = split(a[i], _, "{") - 1
  1043. #           c_ = split(a[i], _, "}") - 1
  1044. #           open_ += o_ - c_
  1045. #           o__ = split(a[i], _, "[") - 1
  1046. #           c__ = split(a[i], _, "]") - 1
  1047. #           open__ += o__ - c__
  1048. #
  1049. #           if (i == l)
  1050. #             r = sprintf("%s%s", r, a[i])
  1051. #           else if (open || open_ || open__)
  1052. #             r = sprintf("%s%s,", r, a[i])
  1053. #           else
  1054. #             r = sprintf("%s%s#[fg=%s,bg=%s,%s]%s", r, a[i], fg[j], bg[j], attr[j], subsep)
  1055. #         }
  1056. #
  1057. #         gsub(/#\[inherit\]/, sprintf("#[default]#[fg=%s,bg=%s,%s]", fg[j], bg[j], attr[j]), r)
  1058. #         return r
  1059. #       }
  1060. #       BEGIN {
  1061. #         FS = "|"
  1062. #         l1 = split(fg_, fg, ",")
  1063. #         l2 = split(bg_, bg, ",")
  1064. #         l3 = split(attr_, attr, ",")
  1065. #         l = l1 < l2 ? (l1 < l3 ? l1 : l3) : (l2 < l3 ? l2 : l3)
  1066. #       }
  1067. #       {
  1068. #         for (i = j = 1; i <= NF; ++i)
  1069. #         {
  1070. #           if (open_ || open || open__)
  1071. #             printf "|%s", subsplit($i)
  1072. #           else
  1073. #             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)
  1074. #
  1075. #           if (!open && !open_ && !open__)
  1076. #           {
  1077. #             j_ = j
  1078. #             j = j % l + 1
  1079. #           }
  1080. #         }
  1081. #       }' << EOF
  1082. # $tmux_conf_theme_status_right
  1083. # EOF
  1084. #     )
  1085. #   fi
  1086. #
  1087. #   # -- variables
  1088. #
  1089. #   tmux set -g '@root' "$tmux_conf_theme_root"
  1090. #
  1091. #   tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-'◼'}
  1092. #   tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-'◻'}
  1093. #   tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-'auto'}
  1094. #   tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-'gradient'}
  1095. #   tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-'gradient'} # red, orange, green
  1096. #   tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-'gradient'} # red, orange, green
  1097. #   tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-'↑'}       # U+2191
  1098. #   tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-'↓'} # U+2193
  1099. #
  1100. #   case "$status_left $status_right" in
  1101. #     *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*)
  1102. #       status_left=$(echo "$status_left" | sed -E \
  1103. #         -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
  1104. #         -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
  1105. #         -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
  1106. #         -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
  1107. #         -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
  1108. #       status_right=$(echo "$status_right" | sed -E \
  1109. #         -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \
  1110. #         -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \
  1111. #         -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
  1112. #         -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
  1113. #         -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
  1114. #
  1115. #       tmux  set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\
  1116. #             set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\
  1117. #             set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\
  1118. #             set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\
  1119. #             set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\
  1120. #             set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\
  1121. #             set -g '@battery_status_charging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_charging")" \;\
  1122. #             set -g '@battery_status_discharging' "$(_decode_unicode_escapes "$tmux_conf_battery_status_discharging")"
  1123. #       status_right="#(cut -c3- ~/.tmux.conf | sh -s _battery)$status_right"
  1124. #       ;;
  1125. #   esac
  1126. #
  1127. #   case "$status_left $status_right" in
  1128. #     *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*)
  1129. #       status_left=$(echo "$status_left" | sed \
  1130. #         -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
  1131. #         -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
  1132. #         -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
  1133. #         -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
  1134. #       status_right=$(echo "$status_right" | sed \
  1135. #         -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} false #D)%g' \
  1136. #         -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} false #D)%g' \
  1137. #         -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_tty} true #D)%g' \
  1138. #         -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D)%g')
  1139. #       ;;
  1140. #   esac
  1141. #
  1142. #   case "$status_left $status_right" in
  1143. #     *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*|*'#{uptime_s}'*)
  1144. #       status_left=$(echo "$status_left" | sed -E \
  1145. #         -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \
  1146. #         -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \
  1147. #         -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \
  1148. #         -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \
  1149. #         -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \
  1150. #         -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g')
  1151. #       status_right=$(echo "$status_right" | sed -E \
  1152. #         -e 's/#\{(\?)?uptime_y/#\{\1@uptime_y/g' \
  1153. #         -e 's/#\{(\?)?uptime_d/#\{\1@uptime_d/g' \
  1154. #         -e '/@uptime_y/ s/@uptime_d/@uptime_dy/g' \
  1155. #         -e 's/#\{(\?)?uptime_h/#\{\1@uptime_h/g' \
  1156. #         -e 's/#\{(\?)?uptime_m/#\{\1@uptime_m/g' \
  1157. #         -e 's/#\{(\?)?uptime_s/#\{\1@uptime_s/g')
  1158. #       status_right="#(cut -c3- ~/.tmux.conf | sh -s _uptime)$status_right"
  1159. #       ;;
  1160. #   esac
  1161. #
  1162. #   case "$status_left $status_right" in
  1163. #     *'#{loadavg}'*)
  1164. #       status_left=$(echo "$status_left" | sed -E \
  1165. #         -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
  1166. #       status_right=$(echo "$status_right" | sed -E \
  1167. #         -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
  1168. #       status_right="#(cut -c3- ~/.tmux.conf | sh -s _loadavg)$status_right"
  1169. #       ;;
  1170. #   esac
  1171. #
  1172. #   status_left=$(echo "$status_left" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g')
  1173. #   status_right=$(echo "$status_right" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g')
  1174. #
  1175. #   tmux  set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\
  1176. #         set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")"
  1177. #
  1178. #   # -- clock -------------------------------------------------------------
  1179. #
  1180. #   tmux_conf_theme_clock_colour=${tmux_conf_theme_clock_colour:-'#00afff'} # light blue
  1181. #   tmux_conf_theme_clock_style=${tmux_conf_theme_clock_style:-'24'}
  1182. #   tmux  setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\
  1183. #         setw -g clock-mode-style "$tmux_conf_theme_clock_style"
  1184. # }
  1185. #
  1186. # _apply_configuration() {
  1187. #
  1188. #   if ! command -v perl > /dev/null 2>&1; then
  1189. #     tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time'
  1190. #     return
  1191. #   fi
  1192. #   if ! command -v sed > /dev/null 2>&1; then
  1193. #     tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time'
  1194. #     return
  1195. #   fi
  1196. #   if ! command -v awk > /dev/null 2>&1; then
  1197. #     tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time'
  1198. #     return
  1199. #   fi
  1200. #
  1201. #   # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
  1202. #   if command -v reattach-to-user-namespace > /dev/null 2>&1; then
  1203. #     default_shell="$(tmux show -gv default-shell)"
  1204. #     case "$default_shell" in
  1205. #       *fish)
  1206. #         tmux set -g default-command "reattach-to-user-namespace -l $default_shell"
  1207. #         ;;
  1208. #       *sh)
  1209. #         tmux set -g default-command "exec $default_shell... 2> /dev/null & reattach-to-user-namespace -l $default_shell"
  1210. #         ;;
  1211. #     esac
  1212. #   fi
  1213. #
  1214. #   _apply_overrides
  1215. #   _apply_bindings
  1216. #   _apply_theme
  1217. #   for name in $(printenv | grep -E -o '^tmux_conf_[^=]+'); do tmux setenv -gu "$name"; done;
  1218. # }
  1219. #
  1220. # _urlview() {
  1221. #   tmux capture-pane -J -S - -E - -b "urlview-$1" -t "$1"
  1222. #   tmux split-window "tmux show-buffer -b urlview-$1 | urlview || true; tmux delete-buffer -b urlview-$1"
  1223. # }
  1224. #
  1225. # _fpp() {
  1226. #   tmux capture-pane -J -S - -E - -b "fpp-$1" -t "$1"
  1227. #   tmux split-window "tmux show-buffer -b fpp-$1 | fpp || true; tmux delete-buffer -b fpp-$1"
  1228. # }
  1229. #
  1230. # "$@"
  1231.  
Tags: tmux
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement