mirror of
1
0
Fork 0

added support for configuration files in the following locations:

- ~/.tmux.conf and ~/.tmux.conf.local
- $XDG_CONFIG_HOME/tmux/tmux.conf and $XDG_CONFIG_HOME/tmux/tmux.conf.local
- ~/.config/tmux/tmux.conf and ~/.config/tmux/tmux.conf.local

location of configuration files is determined by the following environment variables:
- TMUX_CONF
- TMUX_CONF_LOCAL

the TMUX_PROGRAM environment variable contains the path to the tmux executable

resolves #200, resolves #221, resolves #439, resolves #586, resolves #624
This commit is contained in:
Gregory Pakosz 2023-03-05 17:26:21 +01:00
parent c5f598ea86
commit b17d57f325
2 changed files with 263 additions and 197 deletions

View File

@ -1,10 +1,13 @@
# : << EOF # : << 'EOF'
# https://github.com/gpakosz/.tmux # https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license, # (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty. # without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz). # Copyright 2012— Gregory Pakosz (@gpakosz).
# /!\ do not edit this file #
# instead, override settings in ~/.tmux.conf.local, see README.md # ------------------------------------------------------------------------------
# /!\ DO NOT EDIT THIS FILE
# instead, override your .local customization file copy, see README.md /!\
# ------------------------------------------------------------------------------
# -- general ------------------------------------------------------------------- # -- general -------------------------------------------------------------------
@ -25,10 +28,10 @@ setw -q -g utf8 on
set -g history-limit 5000 # boost history set -g history-limit 5000 # boost history
# edit configuration # edit configuration
bind e new-window -n "~/.tmux.conf.local" sh -c '${EDITOR:-vim} ~/.tmux.conf.local && tmux source ~/.tmux.conf && tmux display "~/.tmux.conf sourced"' bind e new-window -n "#{TMUX_CONF_LOCAL}" sh -c '${EDITOR:-vim} "$TMUX_CONF_LOCAL" && "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF" \; display "$TMUX_CONF_LOCAL sourced"'
# reload configuration # reload configuration
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced' bind r run '"$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} source "$TMUX_CONF"' \; display "#{TMUX_CONF} sourced"
# -- display ------------------------------------------------------------------- # -- display -------------------------------------------------------------------
@ -79,7 +82,7 @@ bind > swap-pane -D # swap current pane with the next one
bind < swap-pane -U # swap current pane with the previous one bind < swap-pane -U # swap current pane with the previous one
# maximize current pane # maximize current pane
bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane "#{session_name}" #D' bind + run "cut -c3- '#{TMUX_CONF}' | sh -s _maximize_pane '#{session_name}' '#D'"
# pane resizing # pane resizing
bind -r H resize-pane -L 2 bind -r H resize-pane -L 2
@ -95,17 +98,17 @@ bind -r C-l next-window # select next window
bind Tab last-window # move to last active window bind Tab last-window # move to last active window
# toggle mouse # toggle mouse
bind m run "cut -c3- ~/.tmux.conf | sh -s _toggle_mouse" bind m run "cut -c3- '#{TMUX_CONF}' | sh -s _toggle_mouse"
# -- urlview ------------------------------------------------------------------- # -- urlview -------------------------------------------------------------------
bind U run "cut -c3- ~/.tmux.conf | sh -s _urlview #{pane_id}" bind U run "cut -c3- '#{TMUX_CONF}' | sh -s _urlview '#{pane_id}'"
# -- facebook pathpicker ------------------------------------------------------- # -- facebook pathpicker -------------------------------------------------------
bind F run "cut -c3- ~/.tmux.conf | sh -s _fpp #{pane_id} #{pane_current_path}" bind F run "cut -c3- '#{TMUX_CONF}' | sh -s _fpp '#{pane_id}' '#{pane_current_path}'"
# -- copy mode ----------------------------------------------------------------- # -- copy mode -----------------------------------------------------------------
@ -120,16 +123,16 @@ bind -T copy-mode-vi H send -X start-of-line
bind -T copy-mode-vi L send -X end-of-line bind -T copy-mode-vi L send -X end-of-line
# copy to X11 clipboard # copy to X11 clipboard
if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xsel -i -b"' if -b 'command -v xsel > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | xsel -i -b"'
if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"' if -b '! command -v xsel > /dev/null 2>&1 && command -v xclip > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | xclip -i -selection clipboard >/dev/null 2>&1"'
# copy to Wayland clipboard # copy to Wayland clipboard
if -b 'command -v wl-copy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | wl-copy"' if -b 'command -v wl-copy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | wl-copy"'
# copy to macOS clipboard # copy to macOS clipboard
if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | pbcopy"' if -b 'command -v pbcopy > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | pbcopy"'
if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | reattach-to-user-namespace pbcopy"' if -b 'command -v reattach-to-user-namespace > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | reattach-to-usernamespace pbcopy"'
# copy to Windows clipboard # copy to Windows clipboard
if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "tmux save-buffer - | clip.exe"' if -b 'command -v clip.exe > /dev/null 2>&1' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - | clip.exe"'
if -b '[ -c /dev/clipboard ]' 'bind y run -b "tmux save-buffer - > /dev/clipboard"' if -b '[ -c /dev/clipboard ]' 'bind y run -b "\"\$TMUX_PROGRAM\" \${TMUX_SOCKET:+-S \"\$TMUX_SOCKET\"} save-buffer - > /dev/clipboard"'
# -- buffers ------------------------------------------------------------------- # -- buffers -------------------------------------------------------------------
@ -141,9 +144,21 @@ bind P choose-buffer # choose which buffer to paste from
# -- 8< ------------------------------------------------------------------------ # -- 8< ------------------------------------------------------------------------
source -q ~/.tmux.conf.local %if #{==:#{TMUX_PROGRAM},}
run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' run 'TMUX_PROGRAM="$(lsof -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null || printf tmux)"; "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"'
%endif
%if #{==:#{TMUX_SOCKET},}
run '"$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_SOCKET "#{socket_path}"'
%endif
%if #{==:#{TMUX_CONF},}
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF $(for conf in "$HOME/.tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf" "$HOME/.config/tmux/tmux.conf"; do [ -f "$conf" ] && printf "%s" "$conf" && break; done)'
%endif
%if #{==:#{TMUX_CONF_LOCAL},}
run '"$TMUX_PROGRAM" set-environment -g TMUX_CONF_LOCAL "$TMUX_CONF.local"'
%endif
run '"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"'
run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# EOF # EOF
# #
@ -165,6 +180,24 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# #
# _uname_s=$(uname -s) # _uname_s=$(uname -s)
# #
# [ -z "$TMUX" ] && exit 255
# if [ -z "$TMUX_SOCKET" ]; then
# TMUX_SOCKET=$(printf '%s' "$TMUX" | cut -d, -f1)
# fi
# if [ -z "$TMUX_PROGRAM" ]; then
# TMUX_PID=$(printf '%s' "$TMUX" | cut -d, -f2)
# TMUX_PROGRAM=$(lsof -b -w -a -d txt -p "$TMUX_PID" -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g) { print; exit } } exit 1; {" || readlink "/proc/$TMUX_PID/exe" 2>/dev/null || printf tmux)
# fi
# if [ x"$TMUX_PROGRAM" = x"tmux" ]; then
# tmux() {
# command tmux ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} "$@"
# }
# else
# tmux() {
# "$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} "$@"
# }
# fi
#
# _tmux_version=$(tmux -V | awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}') # _tmux_version=$(tmux -V | awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}')
# #
# _is_true() { # _is_true() {
@ -232,12 +265,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# if [ -z "$restore" ]; then # if [ -z "$restore" ]; then
# [ "$(tmux list-panes -t "$current_session:" | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return # [ "$(tmux list-panes -t "$current_session:" | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return
# current_pane_height=$(tmux display -t "$current_pane" -p "#{pane_height}") # current_pane_height=$(tmux display -t "$current_pane" -p "#{pane_height}")
# info=$(tmux new-window -t "$current_session:" -F "#{session_name}:#{window_index}.#{pane_id}" -P "maximized... 2>/dev/null & tmux setw -t \"$current_session:\" remain-on-exit on; printf \"\\033[\$(tput lines);0fPane has been maximized, press <prefix>+ to restore\n\" '$current_pane'") # info=$(tmux new-window -t "$current_session:" -F "#{session_name}:#{window_index}.#{pane_id}" -P "maximized... 2>/dev/null & \"$TMUX_PROGRAM\" ${TMUX_SOCKET:+-S \"$TMUX_SOCKET\"} setw -t \"$current_session:\" remain-on-exit on; printf \"\\033[\$(tput lines);0fPane has been maximized, press <prefix>+ to restore\n\" '$current_pane'")
# session_window=${info%.*} # session_window=${info%.*}
# new_pane=${info#*.} # new_pane=${info#*.}
# #
# retry=1000 # retry=20
# while [ x"$(tmux list-panes -t "$session_window" -F '#{session_name}:#{window_index}.#{pane_id} #{pane_dead}' 2>/dev/null)" != x"$info 1" ] && [ "$retry" -ne 0 ]; do # while [ x"$("$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} list-panes -t "$session_window" -F '#{session_name}:#{window_index}.#{pane_id} #{pane_dead}' 2>/dev/null)" != x"$info 1" ] && [ "$retry" -ne 0 ]; do
# sleep 0.1 # sleep 0.1
# retry=$((retry - 1)) # retry=$((retry - 1))
# done # done
@ -470,7 +503,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# #
# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")" # battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
# #
# tmux set -g '@battery_bar' "$battery_bar" \;\ # tmux set -g '@battery_bar' "$battery_bar" \;\
# set -g '@battery_hbar' "$battery_hbar" \;\ # set -g '@battery_hbar' "$battery_hbar" \;\
# set -g '@battery_vbar' "$battery_vbar" \;\ # set -g '@battery_vbar' "$battery_vbar" \;\
# set -g '@battery_percentage' "$battery_percentage" # set -g '@battery_percentage' "$battery_percentage"
@ -629,7 +662,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# now=$(date +%s) # now=$(date +%s)
# esac # esac
# # shellcheck disable=SC1004 # # shellcheck disable=SC1004
# awk -v boot="$boot" -v now="$now" ' # awk -v tmux="$TMUX_PROGRAM ${TMUX_SOCKET:+-S "$TMUX_SOCKET"}" -v boot="$boot" -v now="$now" '
# BEGIN { # BEGIN {
# uptime = now - boot # uptime = now - boot
# y = int(uptime / 31536000) # y = int(uptime / 31536000)
@ -639,12 +672,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# m = int(uptime / 60) % 60 # m = int(uptime / 60) % 60
# s = int(uptime) % 60 # s = int(uptime) % 60
# #
# system("tmux set -g @uptime_y " y + 0 " \\; " \ # system(tmux " set -g @uptime_y " y + 0 " \\;" \
# "set -g @uptime_dy " dy + 0 " \\; " \ # " set -g @uptime_dy " dy + 0 " \\;" \
# "set -g @uptime_d " d + 0 " \\; " \ # " set -g @uptime_d " d + 0 " \\;" \
# "set -g @uptime_h " h + 0 " \\; " \ # " set -g @uptime_h " h + 0 " \\;" \
# "set -g @uptime_m " m + 0 " \\; " \ # " set -g @uptime_m " m + 0 " \\;" \
# "set -g @uptime_s " s + 0) # " set -g @uptime_s " s + 0)
# }' # }'
# } # }
# #
@ -741,7 +774,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# _apply_bindings() { # _apply_bindings() {
# cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT # cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
# #
# tmux list-keys | grep -vF 'tmux.conf.local' | grep -E 'new-window|split(-|_)window|new-session|copy-selection|copy-pipe' > "$cfg" # tmux list-keys | grep -vF 'TMUX_CONF_LOCAL' | grep -E 'new-window|split(-|_)window|new-session|copy-selection|copy-pipe' > "$cfg"
# #
# # tmux 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the # # tmux 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the
# # output of list-keys can be truncated # # output of list-keys can be truncated
@ -757,9 +790,9 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true} # tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true}
# if ! _is_disabled "$tmux_conf_new_pane_retain_current_path"; then # if ! _is_disabled "$tmux_conf_new_pane_retain_current_path"; then
# perl -p -i -e " # perl -p -i -e "
# s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{b:pane_tty\}([^\n\1]*)(\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*)\1/run-shell \1cut -c3- ~\/.tmux.conf | sh -s _split_window #{pane_pid} #{b:pane_tty}\2\5\1/g # s/\brun-shell\b\s+(\"|')cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window\s+#\{b:pane_tty\}([^\n\1]*)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\4)([^\n\1]*)\1/run-shell \1cut -c3- \2 | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\3\5\1/g
# ; # ;
# s/\brun-shell\b(\s+((?:\\\\\")?|\"?|'?)cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+((?:\\\\\")?|\"?|'?)#\{b:pane_tty\}\3)(.*?)\2/split-window\4/g # s/\brun-shell\b(?:\s+((?:\\\\\")?|\"?|'?)cut\s+-c3-\s+(?:.+?)\s+\|\s+sh\s+-s\s+_split_window\s+((?:\\\\\")?|\"?|'?)#\{b:pane_tty\}\2)(.*?)\1/split-window\3/g
# ; # ;
# s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" \ # s/\bsplit-window\b([^;}\n]*?)(?:\s+-c\s+((?:\\\\\")?|\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" \
# "$cfg" # "$cfg"
@ -776,12 +809,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# fi # fi
# #
# perl -p -i -e " # perl -p -i -e "
# s/\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1'/g if /\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/"\ # s,\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?(?:\s+(\bssh\b))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!\bssh\b)[^\s]+))*)?,run-shell 'cut -c3- \"$TMUX_CONF\" | sh -s _split_window_ssh #\{pane_pid\} #\{b:pane_tty\}\1',g if /\bsplit-window\b((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?(?:\s+(ssh))((?:(?:[ \t]+-[bdfhIvP])|(?:[ \t]+-[celtF][ \t]+(?!ssh)[^\s]+))*)?/"\
# "$cfg" # "$cfg"
# #
# tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false} # tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false}
# if ! _is_disabled "$tmux_conf_new_pane_reconnect_ssh" && _is_true "$tmux_conf_new_pane_reconnect_ssh"; then # if ! _is_disabled "$tmux_conf_new_pane_reconnect_ssh" && _is_true "$tmux_conf_new_pane_reconnect_ssh"; then
# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\1'/g" "$cfg" # perl -p -i -e "s,\bsplit-window\b([^;}\n\"]*),run-shell 'cut -c3- \"$TMUX_CONF\" | sh -s _split_window #\{pane_pid\} #\{b:pane_tty\}\1',g" "$cfg"
# fi # fi
# #
# if ! _is_disabled "$tmux_conf_new_pane_retain_current_path" && _is_true "$tmux_conf_new_pane_retain_current_path"; then # if ! _is_disabled "$tmux_conf_new_pane_retain_current_path" && _is_true "$tmux_conf_new_pane_retain_current_path"; then
@ -790,9 +823,9 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# ; # ;
# s/\bsplit-window\b/split-window -c '#{pane_current_path}'\1/g # s/\bsplit-window\b/split-window -c '#{pane_current_path}'\1/g
# ; # ;
# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{pane_pid\} #\{b:pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\2'/g if /\bdisplay-menu\b/ # s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _split_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \\\\\"#\{pane_current_path\}\\\\\"\3'/g if /\bdisplay-menu\b/
# ; # ;
# s/\brun-shell\b\s+'cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- ~\/.tmux.conf | sh -s _split_window\1 #\{pane_pid\} #\{b:pane_tty\} -c \"#\{pane_current_path\}\"\2'/g" \ # s/\brun-shell\b\s+'cut\s+-c3-\s+(.+?)\s+\|\s+sh\s+-s\s+_split_window(_ssh)?\s+#\{pane_pid\}\s+#\{b:pane_tty\}([^}\n']*)'/run-shell 'cut -c3- \1 | sh -s _split_window\2 #\{pane_pid\} #\{b:pane_tty\} -c \"#\{pane_current_path\}\"\3'/g" \
# "$cfg" # "$cfg"
# fi # fi
# #
@ -820,7 +853,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# if ! _is_disabled "$tmux_conf_copy_to_os_clipboard" && _is_true "$tmux_conf_copy_to_os_clipboard"; then # if ! _is_disabled "$tmux_conf_copy_to_os_clipboard" && _is_true "$tmux_conf_copy_to_os_clipboard"; then
# perl -p -i -e "s/(?!.*?$command)\bcopy-(?:selection|pipe)(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg" # perl -p -i -e "s/(?!.*?$command)\bcopy-(?:selection|pipe)(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg"
# else # else
# if [ $_tmux_version -ge 320 ]; then # if [ "$_tmux_version" -ge 320 ]; then
# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-pipe\1/g" "$cfg" # perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-pipe\1/g" "$cfg"
# else # else
# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-selection\1/g" "$cfg" # perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2?/copy-selection\1/g" "$cfg"
@ -1202,50 +1235,50 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# # -- variables ------------------------------------------------------------- # # -- variables -------------------------------------------------------------
# #
# set_titles_string=$(printf '%s' "${tmux_conf_theme_terminal_title:-$(tmux show -gv set-titles-string)}" | sed \ # set_titles_string=$(printf '%s' "${tmux_conf_theme_terminal_title:-$(tmux show -gv set-titles-string)}" | sed \
# -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e "s%#{circled_window_index}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#I')%g" \
# -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e "s%#{circled_session_name}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#S')%g" \
# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ # -e "s%#{username}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' false '#D')%g" \
# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ # -e "s%#{hostname}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false false '#h' '#D')%g" \
# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ # -e "s%#{hostname_full}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false true '#H' '#D')%g" \
# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ # -e "s%#{username_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' true '#D')%g" \
# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ # -e "s%#{hostname_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true false '#h' '#D')%g" \
# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # -e "s%#{hostname_full_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true true '#H' '#D')%g")
# #
# window_status_format=$(printf '%s' "${window_status_format:-$(tmux show -gv window-status-format)}" | sed \ # window_status_format=$(printf '%s' "${window_status_format:-$(tmux show -gv window-status-format)}" | sed \
# -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e "s%#{circled_window_index}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#I')%g" \
# -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e "s%#{circled_session_name}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#S')%g" \
# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ # -e "s%#{username}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' false '#D')%g" \
# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ # -e "s%#{hostname}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false false '#h' '#D')%g" \
# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ # -e "s%#{hostname_full}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false true '#H' '#D')%g" \
# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ # -e "s%#{username_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' true '#D')%g" \
# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ # -e "s%#{hostname_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true false '#h' '#D')%g" \
# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # -e "s%#{hostname_full_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true true '#H' '#D')%g")
# #
# window_status_current_format=$(printf '%s' "${window_status_current_format:-$(tmux show -gv window-status-current-format)}" | sed \ # window_status_current_format=$(printf '%s' "${window_status_current_format:-$(tmux show -gv window-status-current-format)}" | sed \
# -e 's%#{circled_window_index}%#(cut -c3- ~/.tmux.conf | sh -s _circled #I)%g' \ # -e "s%#{circled_window_index}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#I')%g" \
# -e 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g' \ # -e "s%#{circled_session_name}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#S')%g" \
# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ # -e "s%#{username}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' false '#D')%g" \
# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ # -e "s%#{hostname}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false false '#h' '#D')%g" \
# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ # -e "s%#{hostname_full}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false true '#H' '#D')%g" \
# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ # -e "s%#{username_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' true '#D')%g" \
# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ # -e "s%#{hostname_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true false '#h' '#D')%g" \
# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # -e "s%#{hostname_full_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true true '#H' '#D')%g")
# #
# status_left=$(printf '%s' "${status_left-$(tmux show -gv status-left)}" | sed \ # status_left=$(printf '%s' "${status_left-$(tmux show -gv status-left)}" | sed \
# -e "s/#{pairing}/#{?session_many_attached,$tmux_conf_theme_pairing ,}/g" \ # -e "s/#{pairing}/#{?session_many_attached,$tmux_conf_theme_pairing ,}/g" \
# -e "s/#{prefix}/#{?client_prefix,$tmux_conf_theme_prefix ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \ # -e "s/#{prefix}/#{?client_prefix,$tmux_conf_theme_prefix ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \
# -e "s/#{mouse}/#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/g" \ # -e "s/#{mouse}/#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/g" \
# -e "s%#{synchronized}%#{?pane_synchronized,$tmux_conf_theme_synchronized ,}%g" \ # -e "s%#{synchronized}%#{?pane_synchronized,$tmux_conf_theme_synchronized ,}%g" \
# -e "s%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g" \ # -e "s%#{circled_session_name}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#S')%g" \
# -e "s%#{root}%#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} #D),root},$tmux_conf_theme_root,}%g") # -e "s%#{root}%#{?#{==:#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' '#D'),root},$tmux_conf_theme_root,}%g")
# #
# status_right=$(printf '%s' "${status_right-$(tmux show -gv status-right)}" | sed \ # status_right=$(printf '%s' "${status_right-$(tmux show -gv status-right)}" | sed \
# -e "s/#{pairing}/#{?session_many_attached,$tmux_conf_theme_pairing ,}/g" \ # -e "s/#{pairing}/#{?session_many_attached,$tmux_conf_theme_pairing ,}/g" \
# -e "s/#{prefix}/#{?client_prefix,$tmux_conf_theme_prefix ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \ # -e "s/#{prefix}/#{?client_prefix,$tmux_conf_theme_prefix ,$(printf "$tmux_conf_theme_prefix" | sed -e 's/./ /g') }/g" \
# -e "s/#{mouse}/#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/g" \ # -e "s/#{mouse}/#{?mouse,$tmux_conf_theme_mouse ,$(printf "$tmux_conf_theme_mouse" | sed -e 's/./ /g') }/g" \
# -e "s%#{synchronized}%#{?pane_synchronized,$tmux_conf_theme_synchronized ,}%g" \ # -e "s%#{synchronized}%#{?pane_synchronized,$tmux_conf_theme_synchronized ,}%g" \
# -e "s%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g" \ # -e "s%#{circled_session_name}%#(cut -c3- '$TMUX_CONF' | sh -s _circled '#S')%g" \
# -e "s%#{root}%#{?#{==:#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} #D),root},$tmux_conf_theme_root,}%g") # -e "s%#{root}%#{?#{==:#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' '#D'),root},$tmux_conf_theme_root,}%g")
# #
# tmux_conf_battery_bar_symbol_full=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_full:-◼}") # tmux_conf_battery_bar_symbol_full=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_full:-◼}")
# tmux_conf_battery_bar_symbol_empty=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_empty:-◻}") # tmux_conf_battery_bar_symbol_empty=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_empty:-◻}")
@ -1256,7 +1289,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191 # tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191
# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193
# #
# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' # _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery_bar"
# _battery_info # _battery_info
# if [ "$charge" != 0 ]; then # if [ "$charge" != 0 ]; then
# case "$status_left $status_right" in # case "$status_left $status_right" in
@ -1273,16 +1306,16 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ # -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \
# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ # -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') # -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
# status_right="#(echo; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" # status_right="#(echo; nice cut -c3- '$TMUX_CONF' | sh -s _battery_status '$tmux_conf_battery_status_charging' '$tmux_conf_battery_status_discharging')$status_right"
# interval=60 # interval=60
# if [ $_tmux_version -ge 320 ]; then # if [ "$_tmux_version" -ge 320 ]; then
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" # tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
# elif [ $_tmux_version -ge 280 ]; then # elif [ "$_tmux_version" -ge 280 ]; then
# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done)$status_right" # status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval; done)$status_right"
# elif [ $_tmux_version -gt 240 ]; then # elif [ "$_tmux_version" -gt 240 ]; then
# status_right="#(echo; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done)$status_right" # status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette'; sleep $interval; done)$status_right"
# else # else
# status_right="#(nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\")$status_right" # status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_bar '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_length' '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_hbar_palette' '$tmux_conf_battery_vbar_palette')$status_right"
# fi # fi
# ;; # ;;
# esac # esac
@ -1291,23 +1324,23 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# case "$status_left $status_right" in # case "$status_left $status_right" in
# *'#{username}'*|*'#{hostname}'*|*'#{hostname_full}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*|*'#{hostname_full_ssh}'*) # *'#{username}'*|*'#{hostname}'*|*'#{hostname_full}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*|*'#{hostname_full_ssh}'*)
# status_left=$(echo "$status_left" | sed \ # status_left=$(echo "$status_left" | sed \
# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ # -e "s%#{username}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' false '#D')%g" \
# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ # -e "s%#{hostname}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false false '#h' '#D')%g" \
# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ # -e "s%#{hostname_full}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false true '#H' '#D')%g" \
# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ # -e "s%#{username_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' true '#D')%g" \
# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ # -e "s%#{hostname_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true false '#h' '#D')%g" \
# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # -e "s%#{hostname_full_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true true '#H' '#D')%g")
# status_right=$(echo "$status_right" | sed \ # status_right=$(echo "$status_right" | sed \
# -e 's%#{username}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} false #D)%g' \ # -e "s%#{username}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' false '#D')%g" \
# -e 's%#{hostname}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false false #h #D)%g' \ # -e "s%#{hostname}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false false '#h' '#D')%g" \
# -e 's%#{hostname_full}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} false true #H #D)%g' \ # -e "s%#{hostname_full}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' false true '#H' '#D')%g" \
# -e 's%#{username_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _username #{pane_pid} #{b:pane_tty} true #D)%g' \ # -e "s%#{username_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _username '#{pane_pid}' '#{b:pane_tty}' true '#D')%g" \
# -e 's%#{hostname_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true false #h #D)%g' \ # -e "s%#{hostname_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true false '#h' '#D')%g" \
# -e 's%#{hostname_full_ssh}%#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_pid} #{b:pane_tty} true true #H #D)%g') # -e "s%#{hostname_full_ssh}%#(cut -c3- '$TMUX_CONF' | sh -s _hostname '#{pane_pid}' '#{b:pane_tty}' true true '#H' '#D')%g")
# ;; # ;;
# esac # esac
# #
# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' # _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _uptime"
# case "$status_left $status_right" in # case "$status_left $status_right" in
# *'#{uptime_'*|*'#{?uptime_'*) # *'#{uptime_'*|*'#{?uptime_'*)
# status_left=$(echo "$status_left" | perl -p -e ' # status_left=$(echo "$status_left" | perl -p -e '
@ -1330,19 +1363,19 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# interval=$(tmux show -gv status-interval) # interval=$(tmux show -gv status-interval)
# ;; # ;;
# esac # esac
# if [ $_tmux_version -ge 320 ]; then # if [ "$_tmux_version" -ge 320 ]; then
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" # tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
# elif [ $_tmux_version -gt 280 ]; then # elif [ "$_tmux_version" -ge 280 ]; then
# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" # status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
# elif [ $_tmux_version -gt 240 ]; then # elif [ "$_tmux_version" -gt 240 ]; then
# status_right="#(echo; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right" # status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _uptime; sleep $interval; done)$status_right"
# else # else
# status_right="#(nice cut -c3- ~/.tmux.conf | sh -s _uptime)$status_right" # status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _uptime)$status_right"
# fi # fi
# ;; # ;;
# esac # esac
# #
# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' # _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _loadavg"
# case "$status_left $status_right" in # case "$status_left $status_right" in
# *'#{loadavg'*|*'#{?loadavg'*) # *'#{loadavg'*|*'#{?loadavg'*)
# status_left=$(echo "$status_left" | sed -E \ # status_left=$(echo "$status_left" | sed -E \
@ -1350,22 +1383,22 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# status_right=$(echo "$status_right" | sed -E \ # status_right=$(echo "$status_right" | sed -E \
# -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g') # -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
# interval=$(tmux show -gv status-interval) # interval=$(tmux show -gv status-interval)
# if [ $_tmux_version -ge 320 ]; then # if [ "$_tmux_version" -ge 320 ]; then
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \$sleep_pid; exit 0' TERM; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \$sleep_pid; sleep_pid=; done" # tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
# elif [ $_tmux_version -gt 280 ]; then # elif [ "$_tmux_version" -ge 280 ]; then
# status_right="#(echo; while [ x\"\$(tmux -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" # status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
# elif [ $_tmux_version -gt 240 ]; then # elif [ "$_tmux_version" -gt 240 ]; then
# status_right="#(echo; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right" # status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _loadavg; sleep $interval; done)$status_right"
# else # else
# status_right="#(nice cut -c3- ~/.tmux.conf | sh -s _loadavg)$status_right" # status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _loadavg)$status_right"
# fi # fi
# ;; # ;;
# esac # esac
# #
# # -- custom variables ------------------------------------------------------ # # -- custom variables ------------------------------------------------------
# #
# if [ -f ~/.tmux.conf.local ] && [ x"$(cut -c3- ~/.tmux.conf.local | sh 2>/dev/null -s printf probe)" = x"probe" ]; then # if [ -f "$TMUX_CONF_LOCAL" ] && [ x"$(cut -c3- "$TMUX_CONF_LOCAL" | sh 2>/dev/null -s printf probe)" = x"probe" ]; then
# replacements=$(perl -n -e 'print if s!^#\s+([^_][^()\s]+)\s*\(\)\s*{\s*(?:#.*)?\n!s%#\\\{\1((?:\\s+(?:[^\{\}]+?|#\\{(?:[^\{\}]+?)\}))*)\\\}%#(cut -c3- ~/.tmux.conf.local | sh -s \1\\1)%g; !p' < ~/.tmux.conf.local) # replacements=$(perl -n -e 'print if s!^#\s+([^_][^()\s]+)\s*\(\)\s*{\s*(?:#.*)?\n!s%#\\\{\1((?:\\s+(?:[^\{\}]+?|#\\{(?:[^\{\}]+?)\}))*)\\\}%#(cut -c3- \"\\\$TMUX_CONF_LOCAL\" | sh -s \1\\1)%g; !p' "$TMUX_CONF_LOCAL")
# status_left=$(echo "$status_left" | perl -p -e "$replacements" || echo "$status_left") # status_left=$(echo "$status_left" | perl -p -e "$replacements" || echo "$status_left")
# status_right=$(echo "$status_right" | perl -p -e "$replacements" || echo "$status_right") # status_right=$(echo "$status_right" | perl -p -e "$replacements" || echo "$status_right")
# fi # fi
@ -1385,58 +1418,74 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# tmux_conf_update_plugins_on_reload="$3" # tmux_conf_update_plugins_on_reload="$3"
# tmux_conf_uninstall_plugins_on_reload="$4" # tmux_conf_uninstall_plugins_on_reload="$4"
# #
# TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-~/.tmux/plugins} # TMUX_PLUGIN_MANAGER_PATH=${TMUX_PLUGIN_MANAGER_PATH:-$(dirname "$TMUX_CONF")/plugins}
# if [ -z "$(tmux show -gv '@plugin')" ] && [ -z "$(tmux show -gv '@tpm_plugins')" ]; then # mkdir -p "$TMUX_PLUGIN_MANAGER_PATH"
#
# tpm_plugins=$(tmux show -gvq '@tpm_plugins' 2>/dev/null)
# if [ -z "$(tmux show -gv '@plugin' 2>/dev/null)" ] && [ -z "$tpm_plugins" ]; then
# if _is_true "$tmux_conf_uninstall_plugins_on_reload" && [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then # if _is_true "$tmux_conf_uninstall_plugins_on_reload" && [ -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then
# tmux display 'Uninstalling tpm and plugins...' # tmux display 'Uninstalling tpm and plugins...'
# rm -rf "$TMUX_PLUGIN_MANAGER_PATH" # rm -rf "$TMUX_PLUGIN_MANAGER_PATH"
# tmux display 'Done uninstalling tpm and plugins...' # tmux display 'Done uninstalling tpm and plugins...'
# fi # fi
# else # else
# if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then # if [ x"$(command tmux display -p '#{pid} #{version} #{socket_path}')" = x"$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then
# if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then # if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then
# install_tpm=true # tpm_plugins=$(cat << EOF | tr ' ' '\n' | awk '/^\s*$/ {next;}; !seen[$0]++ { gsub(/^[ \t]+/,"",$0); gsub(/[ \t]+$/,"",$0); print $0 }'
# tmux display 'Installing tpm and plugins...' # $(awk '/^[ \t]*set(-option)?.*[ \t]@plugin[ \t]/ { gsub(/'\''/, ""); gsub(/'\"'/, ""); print $NF }' "$TMUX_CONF_LOCAL" 2>/dev/null)
# git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm" # EOF
# elif { [ -z "$window_active" ] && _is_true "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_true "$tmux_conf_update_plugins_on_reload"; }; then # )
# update_tpm=true # tmux set -g '@tpm_plugins' "$tpm_plugins"
# tmux display 'Updating tpm and plugins...' #
# (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git fetch -q -p && git checkout -q master && git reset -q --hard origin/master) # if [ ! -d "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]; then
# fi # install_tpm=true
# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then # tmux display 'Installing tpm and plugins...'
# perl -0777 -p -i -e 's/git clone(?!\s+--depth\s+1)/git clone --depth 1/g # git clone --depth 1 https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH/tpm"
# ;s/(install_plugin(.(?!&))*)\n(\s+)done/\1&\n\3done\n\3wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh" # elif { [ -z "$window_active" ] && _is_true "$tmux_conf_update_plugins_on_launch"; } || { [ -n "$window_active" ] && _is_true "$tmux_conf_update_plugins_on_reload"; }; then
# perl -p -i -e 's/git submodule update --init --recursive(?!\s+--depth\s+1)/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh" # update_tpm=true
# perl -p -i -e 's,\$tmux_file\s+>/dev/null\s+2>\&1,$& || { tmux display "Plugin \$(basename \${plugin_path}) failed" && false; },' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/source_plugins.sh" # tmux display 'Updating tpm and plugins...'
# tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" # (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git fetch -q -p && git checkout -q master && git reset -q --hard origin/master)
# fi # fi
# if [ x"$update_tpm" = x"true" ]; then # if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then
# { # perl -0777 -p -i -e 's/git clone(?!\s+--depth\s+1)/git clone --depth 1/g
# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # ;s/(install_plugin(.(?!&))*)\n(\s+)done/\1&\n\3done\n\3wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh"
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ # perl -p -i -e 's/git submodule update --init --recursive(?!\s+--depth\s+1)/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh"
# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # perl -p -i -e 's,\$tmux_file\s+>/dev/null\s+2>\&1,$& || { tmux display "Plugin \$(basename \${plugin_path}) failed" && false; },' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/source_plugins.sh"
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ # tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH"
# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # fi
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ # if [ x"$update_tpm" = x"true" ]; then
# tmux display 'Done updating tpm and plugins...' # {
# } || tmux display 'Failed updating tpm and plugins...' # echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \
# elif [ x"$install_tpm" = x"true" ]; then # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\
# { # echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \
# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/update_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 # echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins all ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \
# tmux display 'Done installing tpm and plugins...' # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\
# } || tmux display 'Failed installing tpm and plugins...' # tmux display 'Done updating tpm and plugins...'
# } || tmux display 'Failed updating tpm and plugins...'
# elif [ x"$install_tpm" = x"true" ]; then
# {
# echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1
# tmux display 'Done installing tpm and plugins...'
# } || tmux display 'Failed installing tpm and plugins...'
# fi
# else
# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..."
# fi # fi
#
# [ -z "$(tmux show -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I'
# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u'
# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u'
# "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed"
# else # else
# tmux display "GitHub doesn't seem to be reachable, skipping installing and/or updating tpm and plugins..." # tmux run -b "sleep \$((#{display-time} / 1000)) && '$TMUX_PROGRAM' set display-time 3000 \; display 'Cannot use tpm which assumes a globally installed tmux' \; set -u display-time"
# fi # fi
# #
# [ -z "$(tmux show -gqv '@tpm-install')" ] && tmux set -g '@tpm-install' 'I' # if [ "$_tmux_version" -gt 260 ]; then
# [ -z "$(tmux show -gqv '@tpm-update')" ] && tmux set -g '@tpm-update' 'u' # tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin' \; set -gu '@tpm_plugins'
# [ -z "$(tmux show -gqv '@tpm-clean')" ] && tmux set -g '@tpm-clean' 'M-u' # else
# [ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" ] && "$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm" || tmux display "One or more tpm plugin(s) failed" # tmux set -g '@tpm-install' '' \; set -g '@tpm-update' '' \; set -g '@tpm-clean' '' \; set -g '@plugin' '' \; set -g '@tpm_plugins' ''
# if [ $_tmux_version -gt 260 ]; then
# tmux set -gu '@tpm-install' \; set -gu '@tpm-update' \; set -gu '@tpm-clean' \; set -gu '@plugin'
# fi # fi
# fi # fi
# } # }
@ -1445,13 +1494,13 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true} # tmux_conf_update_plugins_on_launch=${tmux_conf_update_plugins_on_launch:-true}
# tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true} # tmux_conf_update_plugins_on_reload=${tmux_conf_update_plugins_on_reload:-true}
# tmux_conf_uninstall_plugins_on_reload=${tmux_conf_uninstall_plugins_on_reload:-true} # tmux_conf_uninstall_plugins_on_reload=${tmux_conf_uninstall_plugins_on_reload:-true}
# tmux run -b "cut -c3- ~/.tmux.conf | sh -s __apply_plugins \"$window_active\" \"$tmux_conf_update_plugins_on_launch\" \"$tmux_conf_update_plugins_on_reload\" \"$tmux_conf_uninstall_plugins_on_reload\"" # tmux run -b "cut -c3- '$TMUX_CONF' | sh -s __apply_plugins '$window_active' '$tmux_conf_update_plugins_on_launch' '$tmux_conf_update_plugins_on_reload' '$tmux_conf_uninstall_plugins_on_reload'"
# } # }
# #
# _apply_important() { # _apply_important() {
# cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT # cfg=$(mktemp) && trap 'rm -f $cfg*' EXIT
# #
# if perl -n -e 'print if /^\s*(?:set|bind|unbind).+?#!important\s*$/' ~/.tmux.conf.local 2>/dev/null > "$cfg.local"; then # if perl -n -e 'print if /^\s*(?:set|bind|unbind).+?#!important\s*$/' "$TMUX_CONF_LOCAL" 2>/dev/null > "$cfg.local"; then
# if ! tmux source-file "$cfg.local"; then # if ! tmux source-file "$cfg.local"; then
# verbose_flag=$(tmux source-file -v /dev/null 2> /dev/null && printf -- '-v' || true) # verbose_flag=$(tmux source-file -v /dev/null 2> /dev/null && printf -- '-v' || true)
# while ! out=$(tmux source-file "$verbose_flag" "$cfg.local"); do # while ! out=$(tmux source-file "$verbose_flag" "$cfg.local"); do
@ -1477,7 +1526,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server' # tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time \; run "sleep 3" \; kill-server'
# return # return
# fi # fi
# if [ $_tmux_version -lt 240 ]; then # if [ "$_tmux_version" -lt 240 ]; then
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.4+" \; set -u display-time \; run "sleep 3" \; kill-server' # tmux run -b 'tmux set display-time 3000 \; display "This configuration requires tmux 2.4+" \; set -u display-time \; run "sleep 3" \; kill-server'
# return # return
# fi # fi
@ -1518,12 +1567,12 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# #
# _urlview() { # _urlview() {
# tmux capture-pane -J -S - -E - -b "urlview-$1" -t "$1" # tmux capture-pane -J -S - -E - -b "urlview-$1" -t "$1"
# tmux split-window "tmux show-buffer -b urlview-$1 | urlview || true; tmux delete-buffer -b urlview-$1" # tmux split-window "'$TMUX_PROGRAM' ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} show-buffer -b 'urlview-$1' | urlview || true; '$TMUX_PROGRAM' ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} delete-buffer -b 'urlview-$1'"
# } # }
# #
# _fpp() { # _fpp() {
# tmux capture-pane -J -S - -E - -b "fpp-$1" -t "$1" # tmux capture-pane -J -S - -E - -b "fpp-$1" -t "$1"
# tmux split-window -c $2 "tmux show-buffer -b fpp-$1 | fpp || true; tmux delete-buffer -b fpp-$1" # tmux split-window -c "$2" "'$TMUX_PROGRAM' ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} show-buffer -b 'fpp-$1' | fpp || true; '$TMUX_PROGRAM' ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} delete-buffer -b 'fpp-$1'"
# } # }
# #
# "$@" # "$@"

109
README.md
View File

@ -14,9 +14,14 @@ Requirements:
- awk, perl and sed - awk, perl and sed
- outside of tmux, `$TERM` must be set to `xterm-256color` - outside of tmux, `$TERM` must be set to `xterm-256color`
To install, run the following from your terminal: (you may want to backup your ⚠️ Before installing, you may want to backup your existing configuration.
existing `~/.tmux.conf` first)
You can install Oh my tmux! at any of the following locations:
- `~`
- `$XDG_CONFIG_HOME/tmux`
- `~/.config/tmux`
Installing in `~`:
``` ```
$ cd $ cd
$ git clone https://github.com/gpakosz/.tmux.git $ git clone https://github.com/gpakosz/.tmux.git
@ -24,28 +29,39 @@ $ ln -s -f .tmux/.tmux.conf
$ cp .tmux/.tmux.conf.local . $ cp .tmux/.tmux.conf.local .
``` ```
💡 You can clone the repository anywhere you want, provided you create the Installing in `$XDG_CONFIG_HOME/tmux`:
proper `~/.tmux.conf` symlink and you copy the `.tmux.conf.local` sample file in
your home directory:
``` ```
$ git clone https://github.com/gpakosz/.tmux.git /path/to/oh-my-tmux $ git clone https://github.com/gpakosz/.tmux.git "/path/to/oh-my-tmux"
$ ln -s -f /path/to/oh-my-tmux/.tmux.conf ~/.tmux.conf $ mkdir -p "$XDG_CONFIG_HOME/tmux"
$ cp /path/to/oh-my-tmux/.tmux.conf.local ~/.tmux.conf.local $ ln -s "/path/to/oh-my-tmux/.tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf"
$ cp "/path/to/oh-my-tmux/.tmux.conf.local" "$XDG_CONFIG_HOME/tmux/tmux.conf.local"
``` ```
Then proceed to [customize] your `~/.tmux.conf.local` copy. Installing in `~/.config/tmux`:
```
$ git clone https://github.com/gpakosz/.tmux.git "/path/to/oh-my-tmux"
$ mkdir -p "~/.config/tmux"
$ ln -s "/path/to/oh-my-tmux/.tmux.conf" "~/.config/tmux/tmux.conf"
$ cp "/path/to/oh-my-tmux/.tmux.conf.local" "~/.config/tmux/tmux.conf.local"
```
⚠️ When installing `$XDG_CONFIG_HOME/tmux` or `~/.config/tmux`, the configuration
file names don't have a leading `.` character.
[customize]: #configuration ❗️ You should never alter the main `.tmux.conf` or `tmux.conf` file. If you do,
you're on your own. Instead, every customization should happen in your
`.tmux.conf.local` or `tmux.conf.local` customization file copy.
If you're a Vim user, setting the `$EDITOR` environment variable to `vim` will If you're a Vim user, setting the `$EDITOR` environment variable to `vim` will
enable and further customize the vi-style key bindings (see tmux manual). enable and further customize the vi-style key bindings (see tmux manual).
If you're new to tmux, I recommend you read [tmux 2: Productive Mouse-Free If you're new to tmux, I recommend you to read [tmux 2: Productive Mouse-Free
Development][bhtmux2] by [@bphogan]. Development][bhtmux2] by [@bphogan].
[bhtmux2]: https://pragprog.com/book/bhtmux2/tmux-2 Now proceed to [adjust] your `.local` customization file copy.
[bhtmux2]: https://pragprog.com/titles/bhtmux2/tmux-2
[@bphogan]: https://twitter.com/bphogan [@bphogan]: https://twitter.com/bphogan
[adjust]: #configuration
Troubleshooting Troubleshooting
--------------- ---------------
@ -69,23 +85,23 @@ Troubleshooting
This can also happen on macOS when using iTerm2 and "Use Unicode version 9 This can also happen on macOS when using iTerm2 and "Use Unicode version 9
character widths" is enabled in `Preferences... > Profiles > Text` character widths" is enabled in `Preferences... > Profiles > Text`
For that reason, the default `~/.tmux.conf.local` file stopped using Unicode For that reason, the default sample `.local` customization file stopped using
characters for which width changed in between Unicode 8.0 and 9.0 standards, Unicode characters for which width changed in between Unicode 8.0 and 9.0
as well as Emojis. standards, as well as Emojis.
- **I installed Powerline and/or (patched) fonts but can't see Powerline - **I installed Powerline and/or (patched) fonts but can't see Powerline
symbols.** symbols.**
First, you don't need to install Powerline. You only need fonts patched with First, you don't need to install Powerline. You only need fonts patched with
Powerline symbols or the standalone `PowerlineSymbols.otf` font. Then make Powerline symbols or the standalone `PowerlineSymbols.otf` font. Then make
sure your `~/.tmux.conf.local` copy uses the right code points for sure your `.local` customization file copy uses the Powerline code points for
`tmux_conf_theme_left_separator_XXX` values. `tmux_conf_theme_left_separator_XXX` values.
- **I'm using Bash On Windows (WSL), colors and Powerline look are broken.** - **I'm using Bash On Windows (WSL), colors and the Powerline look are broken.**
There is currently a [bug][1681] in the new console powering Bash On Windows There is currently a [bug][1681] in the new console powering Bash On Windows
preventing text attributes (bold, underscore, ...) to combine properly with preventing text attributes (bold, underscore, ...) to combine properly with
colors. The workaround is to search your `~/.tmux.conf.local` copy and colors. The workaround is to search your `.local` customization file copy and
replace attributes with `'none'`. replace attributes with `'none'`.
Also, until Window's console replaces its GDI based render with a DirectWrite Also, until Window's console replaces its GDI based render with a DirectWrite
@ -150,8 +166,8 @@ list of key bindings:
This configuration uses the following bindings: This configuration uses the following bindings:
- `<prefix> e` opens `~/.tmux.conf.local` with the editor defined by the - `<prefix> e` opens the `.local` customization file copy with the editor
`$EDITOR` environment variable (defaults to `vim` when empty) defined by the `$EDITOR` environment variable (defaults to `vim` when empty)
- `<prefix> r` reloads the configuration - `<prefix> r` reloads the configuration
- `C-l` clears both the screen and the tmux history - `C-l` clears both the screen and the tmux history
@ -197,14 +213,16 @@ Configuration
------------- -------------
While this configuration tries to bring sane default settings, you may want to While this configuration tries to bring sane default settings, you may want to
customize it further to your needs. Instead of altering the `~/.tmux.conf` file customize it further to your needs.
and diverging from upstream, the proper way is to edit the `~/.tmux.conf.local`
file.
Please refer to the sample `.tmux.conf.local` file to know more about variables ❗️ Again, you should never alter the main `.tmux.conf` or `tmux.conf` file.
you can adjust to alter different behaviors. Pressing `<prefix> e` will open If you do, you're on your own.
`~/.tmux.conf.local` with the editor defined by the `$EDITOR` environment
variable (defaults to `vim` when empty). Please refer to the sample `.local` customization file to know more about the
variables that allow you to alter different behaviors. Upon successful
installation, pressing `<prefix> e` will open your `.local` customization file
copy with the editor defined by the `$EDITOR` environment variable (defaults to
`vim` when empty).
### Enabling the Powerline look ### Enabling the Powerline look
@ -226,12 +244,9 @@ To make use of these symbols, there are several options:
[powerline patched fonts]: https://github.com/powerline/fonts [powerline patched fonts]: https://github.com/powerline/fonts
[powerline font]: https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf [powerline font]: https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
[terminal support]: http://powerline.readthedocs.io/en/master/usage.html#usage-terminal-emulators [terminal support]: http://powerline.readthedocs.io/en/master/usage.html#usage-terminal-emulators
[Powerline manual]: http://powerline.readthedocs.org/en/latest/installation.html#fonts-installation
Please see the [Powerline manual] for further details. Then edit your `.local` customization file copy (with `<prefix> e`) and adjust
the following variables:
Then edit your `~/.tmux.conf.local` copy (with `<prefix> e`) and adjust the
following variables:
``` ```
tmux_conf_theme_left_separator_main='\uE0B0' tmux_conf_theme_left_separator_main='\uE0B0'
@ -239,12 +254,16 @@ tmux_conf_theme_left_separator_sub='\uE0B1'
tmux_conf_theme_right_separator_main='\uE0B2' tmux_conf_theme_right_separator_main='\uE0B2'
tmux_conf_theme_right_separator_sub='\uE0B3' tmux_conf_theme_right_separator_sub='\uE0B3'
``` ```
The [Powerline manual] contains further details on how to install fonts
containing the Powerline symbols. You don't need to install Powerline itself
though.
[Powerline manual]: http://powerline.readthedocs.org/en/latest/installation.html#fonts-installation
### Configuring the status line ### Configuring the status line
Contrary to the first iterations of this configuration, by now you have total Edit your `.local` customization file copy (`<prefix> e`) and adjust the
control on the content and order of `status-left` and `status-right`.
Edit your `~/.tmux.conf.local` copy (`<prefix> e`) and adjust the
`tmux_conf_theme_status_left` and `tmux_conf_theme_status_right` variables to `tmux_conf_theme_status_left` and `tmux_conf_theme_status_right` variables to
your own preferences. your own preferences.
@ -272,7 +291,7 @@ This configuration supports the following builtin variables:
- `#{username_ssh}`: SSH aware username information, blank when not connected - `#{username_ssh}`: SSH aware username information, blank when not connected
to a remote server through SSH/Mosh to a remote server through SSH/Mosh
Beside custom variables mentioned above, the `tmux_conf_theme_status_left` and Beside the variables mentioned above, the `tmux_conf_theme_status_left` and
`tmux_conf_theme_status_right` variables support usual tmux syntax, e.g. using `tmux_conf_theme_status_right` variables support usual tmux syntax, e.g. using
`#()` to call an external command that inserts weather information provided by `#()` to call an external command that inserts weather information provided by
[wttr.in]: [wttr.in]:
@ -286,8 +305,8 @@ minutes whatever the value of `status-interval`.
[wttr.in]: https://github.com/chubin/wttr.in#one-line-output [wttr.in]: https://github.com/chubin/wttr.in#one-line-output
💡 You can also define your own custom variables. See the sample 💡 You can also define your own custom variables by writing special functions,
`.tmux.conf.local` file for instructions. see the sample `.local` customization file for instructions.
Finally, remember `tmux_conf_theme_status_left` and Finally, remember `tmux_conf_theme_status_left` and
`tmux_conf_theme_status_right` end up being given to tmux as `status-left` and `tmux_conf_theme_status_right` end up being given to tmux as `status-left` and
@ -296,7 +315,7 @@ character has a special meaning and needs to be escaped by doubling it, e.g.
``` ```
tmux_conf_theme_status_right='#(echo foo %% bar)' tmux_conf_theme_status_right='#(echo foo %% bar)'
``` ```
See `man 3 strftime`. See also `man 3 strftime`.
### Using TPM plugins ### Using TPM plugins
@ -305,17 +324,15 @@ This configuration now comes with built-in [TPM] support:
- whenever a plugin introduces a variable to be used in `status-left` or - whenever a plugin introduces a variable to be used in `status-left` or
`status-right`, you can use it in `tmux_conf_theme_status_left` and `status-right`, you can use it in `tmux_conf_theme_status_left` and
`tmux_conf_theme_status_right` variables, see instructions above 👆 `tmux_conf_theme_status_right` variables, see instructions above 👆
- ⚠️ do not add `set -g @plugin 'tmux-plugins/tpm'` - ⚠️ do not add `set -g @plugin 'tmux-plugins/tpm'` to any configuration file
- ⚠️ do not add `run '~/.tmux/plugins/tpm/tpm'` to `~/.tmux.conf` or your - ⛔️ do not add `run '~/.tmux/plugins/tpm/tpm'` to any configuration file
- `~/.tmux.conf.local` copy ← people who are used to alter
`.tmux.conf` to add TPM support will have to adapt their configuration
⚠️ The TPM bindings differ slightly from upstream: ⚠️ The TPM bindings differ slightly from upstream:
- installing plugins: `<prefix> + I` - installing plugins: `<prefix> + I`
- uninstalling plugins: `<prefix> + Alt + u` - uninstalling plugins: `<prefix> + Alt + u`
- updating plugins: `<prefix> + u` - updating plugins: `<prefix> + u`
See `~/.tmux.conf.local` for instructions. See the sample `.local` customization file for instructions.
[TPM]: https://github.com/tmux-plugins/tpm [TPM]: https://github.com/tmux-plugins/tpm