Advertisement
Guest User

Untitled

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