commit
336877ea4e
2 changed files with 90 additions and 95 deletions
180
.tmux.conf
180
.tmux.conf
|
@ -24,7 +24,7 @@ setw -q -g utf8 on
|
|||
set -g history-limit 5000 # boost history
|
||||
|
||||
# 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 source ~/.tmux.conf && tmux display \"~/.tmux.conf sourced\"'"
|
||||
|
||||
# reload configuration
|
||||
bind r source-file ~/.tmux.conf \; display '~/.tmux.conf sourced'
|
||||
|
@ -168,7 +168,7 @@ if '[ -f ~/.tmux.conf.local ]' 'source ~/.tmux.conf.local'
|
|||
# -- 8< ------------------------------------------------------------------------
|
||||
|
||||
run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
|
||||
run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3000 \; display "This configuration will soon require tmux >= 2.4" \; set -u display-time || true'
|
||||
run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-time 3000 \; display "This configuration will soon require tmux >= 2.4" \; set -u display-time || true'
|
||||
|
||||
|
||||
# EOF
|
||||
|
@ -206,23 +206,9 @@ run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3
|
|||
# fi
|
||||
# }
|
||||
#
|
||||
# if command -v perl > /dev/null 2>&1; then
|
||||
# _decode_unicode_escapes() {
|
||||
# printf '%s' "$*" | perl -CS -pe 's/(\\u([0-9A-Fa-f]{1,4})|\\U([0-9A-Fa-f]{1,8}))/chr(hex($2.$3))/eg' 2>/dev/null
|
||||
# }
|
||||
# elif bash --norc --noprofile -c '[[ ! $BASH_VERSION < 4.2. ]]' > /dev/null 2>&1; then
|
||||
# _decode_unicode_escapes() {
|
||||
# bash --norc --noprofile -c "printf '%b' '$*'"
|
||||
# }
|
||||
# elif command -v python > /dev/null 2>&1; then
|
||||
# _decode_unicode_escapes() {
|
||||
# python -c "import re; import sys; sys.stdout.write(re.sub(r'\\\U([0-9A-Fa-f]{1,8})', lambda match: r'\U%s' % match.group(1).zfill(8), r'$*').encode().decode('unicode-escape', 'ignore'))"
|
||||
# }
|
||||
# else
|
||||
# _decode_unicode_escapes() {
|
||||
# printf '%b' "$*"
|
||||
# }
|
||||
# fi
|
||||
# _decode_unicode_escapes() {
|
||||
# printf '%s' "$*" | perl -CS -pe 's/(\\u([0-9A-Fa-f]{1,4})|\\U([0-9A-Fa-f]{1,8}))/chr(hex($2.$3))/eg' 2>/dev/null
|
||||
# }
|
||||
#
|
||||
# _maximize_pane() {
|
||||
# current_session=${1:-$(tmux display -p '#{session_name}')}
|
||||
|
@ -680,65 +666,65 @@ run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3
|
|||
# }
|
||||
#
|
||||
# _apply_bindings() {
|
||||
# line=$(tmux list-keys | grep new-window | head -1)
|
||||
# prefix=${line%new-window*}
|
||||
# column=${#prefix}
|
||||
# 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 3.0 doesn't include 02254d1e5c881be95fd2fc37b4c4209640b6b266 and the
|
||||
# # output of list-keys can be truncated
|
||||
# perl -p -i -e "s/'#\{\?window_zoomed_flag,Unzoom,Zoom\}' 'z' \{resize-pane -$/'#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}\"/g" "$cfg"
|
||||
#
|
||||
# tmux_conf_new_window_retain_current_path=${tmux_conf_new_window_retain_current_path:-false}
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# left=$(printf '%s' "$line" | cut -c-"$column" | sed -E -e 's/[^ \ta-zA-Z0-9,._+@%/-]/\\&/g')
|
||||
# if _is_enabled "$tmux_conf_new_window_retain_current_path"; then
|
||||
# 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')
|
||||
# else
|
||||
# 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')
|
||||
# fi
|
||||
# eval "tmux $left $right" 2>/dev/null || true
|
||||
# done << EOF
|
||||
# $(tmux list-keys 2>/dev/null | grep -E 'new-window(\s+-c\s+"#{pane_current_path}"|$)')
|
||||
# EOF
|
||||
# if _is_enabled "$tmux_conf_new_window_retain_current_path"; then
|
||||
# perl -p -i \
|
||||
# -e "s/\b(new-window)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
|
||||
# -e ';' \
|
||||
# -e "s/\bnew-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/new-window -c '#{pane_current_path}'/g" \
|
||||
# "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\bnew-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/new-window\1/g" "$cfg"
|
||||
# fi
|
||||
#
|
||||
# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-true}
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# left=$(printf '%s' "$line" | cut -c-"$column" | sed -E -e 's/[^ \ta-zA-Z0-9,._+@%/-]/\\&/g')
|
||||
# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# 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 '/#\{pane_current_path\}/!s/split(-|_)window([ \t]+#\{pane_tty\})?([ \t]+-(h|v))?/& -c "#{pane_current_path}"/g')
|
||||
# else
|
||||
# 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/[ \t]+(-c[ \t]+(\\")?"#\{pane_current_path\}"(\\")?|-c #\{pane_current_path\})//g')
|
||||
# fi
|
||||
# eval "tmux $left $right" 2>/dev/null || true
|
||||
# done << EOF
|
||||
# $(tmux list-keys 2>/dev/null | grep -E 'split(-|_)window')
|
||||
# EOF
|
||||
# tmux_conf_new_pane_retain_current_path=${tmux_conf_new_pane_retain_current_path:-false}
|
||||
# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# perl -p -i -e "s/\bsplit-window\b(?!([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2))/split-window -c '#{pane_current_path}'/g" "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)/split-window\1/g" "$cfg"
|
||||
# fi
|
||||
#
|
||||
# tmux_conf_new_pane_reconnect_ssh=${tmux_conf_new_pane_reconnect_ssh:-false}
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# left=$(printf '%s' "$line" | cut -c-"$column" | sed -E -e 's/[^ \ta-zA-Z0-9,._+@%/-]/\\&/g')
|
||||
# if _is_enabled "$tmux_conf_new_pane_reconnect_ssh"; then
|
||||
# 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 '/_split_window/!s/"/\\"/g' -e 's/split-window([^;]*)/run-shell "cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1"/g')
|
||||
# if _is_enabled "$tmux_conf_new_pane_reconnect_ssh"; then
|
||||
# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# perl -p -i \
|
||||
# -e "s/\bsplit-window\b([^;}\n\"]*?)(?:\s+-c\s+(\\\?\"?|'?)#\{pane_current_path\}\2)([^;}\n\"]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1\3 -c #\{pane_current_path\}'/g" \
|
||||
# -e ';' \
|
||||
# -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1 -c \\\\\"#{pane_current_path}\\\\\"\"/g" \
|
||||
# "$cfg"
|
||||
# else
|
||||
# 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')
|
||||
# perl -p -i \
|
||||
# -e "s/\bsplit-window\b([^;}\n]*)/run-shell 'cut -c3- ~\/\.tmux\.conf | sh -s _split_window #{pane_tty}\1'/g" \
|
||||
# -e ';' \
|
||||
# -e "s/\b_split_window\b\s+#\{pane_tty\}(.*?)\s+-c\s+\\\\\"#\{pane_current_path\}\\\\\"\"/_split_window #{pane_tty}\1\"/g" \
|
||||
# "$cfg"
|
||||
# fi
|
||||
# eval "tmux $left $right" 2>/dev/null || true
|
||||
# done << EOF
|
||||
# $(tmux list-keys 2>/dev/null | grep -E 'split(-|_)window')
|
||||
# EOF
|
||||
# else
|
||||
# if _is_enabled "$tmux_conf_new_pane_retain_current_path"; then
|
||||
# perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*?)\s+-c\s+#\{pane_current_path\}\2/split-window\3 -c '#{pane_current_path}'/g" "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\brun-shell\b(\s+(\"|')cut\s+-c3-\s+~\/\.tmux\.conf\s+\|\s+sh\s+-s\s+_split_window\s+#\{pane_tty\})(.*)\2/split-window\3/g" "$cfg"
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# tmux_conf_new_session_prompt=${tmux_conf_new_session_prompt:-false}
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# left=$(printf '%s' "$line" | cut -c-"$column" | sed -E -e 's/[^ \ta-zA-Z0-9,._+@%/-]/\\&/g')
|
||||
# if _is_enabled "$tmux_conf_new_session_prompt"; then
|
||||
# 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')
|
||||
# else
|
||||
# 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')
|
||||
# fi
|
||||
# eval "tmux $left $right" 2>/dev/null || true
|
||||
# done << EOF
|
||||
# $(tmux list-keys 2>/dev/null | grep 'new-session')
|
||||
# EOF
|
||||
# if _is_enabled "$tmux_conf_new_session_prompt"; then
|
||||
# perl -p -i \
|
||||
# -e "s/(?<!command-prompt -p )\b(new-session)\b(?!\s+-)/{$&}/g if /\bdisplay-menu\b/" \
|
||||
# -e ';' \
|
||||
# -e "s/(?<!\bcommand-prompt -p )\bnew-session\b(?! -s)/command-prompt -p new-session 'new-session -s \"%%\"'/g" \
|
||||
# "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\bcommand-prompt\s+-p\s+new-session\s+'new-session\s+-s\s+\"%%\"'/new-session/g" "$cfg"
|
||||
# fi
|
||||
#
|
||||
# tmux_conf_copy_to_os_clipboard=${tmux_conf_copy_to_os_clipboard:-false}
|
||||
# command -v pbcopy > /dev/null 2>&1 && command='pbcopy'
|
||||
|
@ -749,27 +735,22 @@ run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3
|
|||
# [ -c /dev/clipboard ] && command='cat > \/dev\/clipboard'
|
||||
#
|
||||
# if [ -n "$command" ]; then
|
||||
# # shellcheck disable=SC2086
|
||||
# for table in "" "-t emacs-copy" "-t vi-copy"; do
|
||||
# line=$(tmux list-keys $table 2>/dev/null | grep -E 'copy-selection|copy-pipe' | head -1)
|
||||
# [ -z "$line" ] && continue
|
||||
# prefix=${line%copy-*}
|
||||
# column=${#prefix}
|
||||
# if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then
|
||||
# perl -p -i -e "s/\bcopy-selection(-and-cancel)?\b/copy-pipe\1 '$command'/g" "$cfg"
|
||||
# else
|
||||
# perl -p -i -e "s/\bcopy-pipe(-and-cancel)?\b\s+(\"|')?$command\2/copy-selection\1/g" "$cfg"
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# left=$(printf '%s' "$line" | cut -c-"$column" | sed -E -e 's/[^ \ta-zA-Z0-9,._+@%/-]/\\&/g')
|
||||
# if _is_enabled "$tmux_conf_copy_to_os_clipboard"; then
|
||||
# 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")
|
||||
# else
|
||||
# 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")
|
||||
# fi
|
||||
# eval "tmux $left $right" 2>/dev/null || true
|
||||
# done << EOF
|
||||
# $(tmux list-keys $table 2>/dev/null | grep -E 'copy-selection|copy-pipe')
|
||||
# EOF
|
||||
# done
|
||||
# fi
|
||||
# # until tmux >= 3.0, output of tmux list-keys can't be consumed back by tmux source-file without applying some escapings
|
||||
# awk < "$cfg" \
|
||||
# '{i = $2 == "-T" ? 4 : 5; gsub(/^[;]$/, "\\\\&", $i); gsub(/^[$"#~]$/, "'"'"'&'"'"'", $i); gsub(/^['"'"']$/, "\"&\"", $i); print}' > "$cfg.in"
|
||||
#
|
||||
# # ignore bindings with errors
|
||||
# while ! out=$(tmux source-file "$cfg.in"); do
|
||||
# line=$(printf "%s" "$out" | cut -d':' -f2)
|
||||
# perl -n -i -e "if ($. != $line) { print }" "$cfg.in"
|
||||
# done
|
||||
# }
|
||||
#
|
||||
# _apply_theme() {
|
||||
|
@ -817,10 +798,10 @@ run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3
|
|||
#
|
||||
# # -- status line -------------------------------------------------------
|
||||
#
|
||||
# tmux_conf_theme_left_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_main-''}")
|
||||
# tmux_conf_theme_left_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_sub-'|'}")
|
||||
# tmux_conf_theme_right_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_main-''}")
|
||||
# tmux_conf_theme_right_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_sub-'|'}")
|
||||
# tmux_conf_theme_left_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_main-}")
|
||||
# tmux_conf_theme_left_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_left_separator_sub-|}")
|
||||
# tmux_conf_theme_right_separator_main=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_main-}")
|
||||
# tmux_conf_theme_right_separator_sub=$(_decode_unicode_escapes "${tmux_conf_theme_right_separator_sub-|}")
|
||||
#
|
||||
# tmux_conf_theme_message_fg=${tmux_conf_theme_message_fg:-'#000000'} # black
|
||||
# tmux_conf_theme_message_bg=${tmux_conf_theme_message_bg:-'#ffff00'} # yellow
|
||||
|
@ -1194,6 +1175,19 @@ run -b '[ -z "#{session_id}" ] && [ -z "#{version}" ] && tmux set display-time 3
|
|||
#
|
||||
# _apply_configuration() {
|
||||
#
|
||||
# if ! command -v perl > /dev/null 2>&1; then
|
||||
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires perl" \; set -u display-time'
|
||||
# return
|
||||
# fi
|
||||
# if ! command -v sed > /dev/null 2>&1; then
|
||||
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires sed" \; set -u display-time'
|
||||
# return
|
||||
# fi
|
||||
# if ! command -v awk > /dev/null 2>&1; then
|
||||
# tmux run -b 'tmux set display-time 3000 \; display "This configuration requires awk" \; set -u display-time'
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# # see https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
|
||||
# if command -v reattach-to-user-namespace > /dev/null 2>&1; then
|
||||
# default_shell="$(tmux show -gv default-shell)"
|
||||
|
|
|
@ -10,8 +10,9 @@ Installation
|
|||
|
||||
Requirements:
|
||||
|
||||
- tmux **`>= 2.1`** running inside Linux, Mac, OpenBSD, Cygwin or WSL (Bash on
|
||||
Ubuntu on Windows)
|
||||
- tmux **`>= 2.1`** (soon `>= 2.4`) running inside Linux, Mac, OpenBSD, Cygwin
|
||||
or WSL
|
||||
- awk, perl and sed
|
||||
- outside of tmux, `$TERM` must be set to `xterm-256color`
|
||||
|
||||
To install, run the following from your terminal: (you may want to backup your
|
||||
|
|
Loading…
Reference in a new issue