1
0
Fork 0
mirror of synced 2024-12-22 06:41:07 -05:00

added a way to mark set/bind/unbind commands as important in ~/.tmux.conf.local, closes #571

inspired by css, any set/bind/unbind command ending with #!important will be
executed honored, e.g.:

bind-key -T copy-mode-vi Escape send-keys -X clear-selection #!important
This commit is contained in:
Gregory Pakosz 2022-07-14 17:29:15 +02:00
parent 52f1c4a3b1
commit 18a111ff93
2 changed files with 29 additions and 15 deletions

View file

@ -165,13 +165,9 @@ bind p paste-buffer # paste from the top paste buffer
bind P choose-buffer # choose which buffer to paste from bind P choose-buffer # choose which buffer to paste from
# -- user defined overrides ----------------------------------------------------
source -q ~/.tmux.conf.local
# -- 8< ------------------------------------------------------------------------ # -- 8< ------------------------------------------------------------------------
source -q ~/.tmux.conf.local
run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
@ -719,22 +715,22 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# _split_window_ssh "$@" # _split_window_ssh "$@"
# } # }
# #
# _apply_overrides() { # _apply_24b() {
# tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-auto} # tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-auto}
# tmux_conf_24b_colour=${tmux_conf_24b_colour:-$tmux_conf_theme_24b_colour} # tmux_conf_24b_colour=${tmux_conf_24b_colour:-$tmux_conf_theme_24b_colour}
# if [ x"$tmux_conf_24b_colour" = x"auto" ]; then # if [ x"$tmux_conf_24b_colour" = x"auto" ]; then
# case "$COLORTERM" in # case "$COLORTERM" in
# truecolor|24bit) # truecolor|24bit)
# apply_overrides=true # apply_24b=true
# ;; # ;;
# esac # esac
# if [ x"$apply_overrides" = x"" ] && [ x"$(tput colors)" = x"16777216" ]; then # if [ x"$apply_24b" = x"" ] && [ x"$(tput colors)" = x"16777216" ]; then
# apply_overrides=true # apply_24b=true
# fi # fi
# elif _is_true "$tmux_conf_24b_colour"; then # elif _is_true "$tmux_conf_24b_colour"; then
# apply_overrides=true # apply_24b=true
# fi # fi
# if [ x"$apply_overrides" = x"true" ]; then # if [ x"$apply_24b" = x"true" ]; then
# case "$TERM" in # case "$TERM" in
# screen-*|tmux-*) # screen-*|tmux-*)
# ;; # ;;
@ -1453,6 +1449,20 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# 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() {
# 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 ! tmux source-file "$cfg.local"; then
# verbose_flag=$(tmux source-file -v /dev/null 2> /dev/null && printf -- '-v' || true)
# while ! out=$(tmux source-file "$verbose_flag" "$cfg.local"); do
# line=$(printf "%s" "$out" | tail -1 | cut -d':' -f2)
# perl -n -i -e "if ($. != $line) { print }" "$cfg.local"
# done
# fi
# fi
# }
#
# _apply_configuration() { # _apply_configuration() {
# #
# window_active="$(tmux display -p '#{window_active}' 2>/dev/null || true)" # window_active="$(tmux display -p '#{window_active}' 2>/dev/null || true)"
@ -1495,15 +1505,16 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration'
# ;; # ;;
# esac # esac
# #
# _apply_overrides # _apply_24b
# _apply_theme& # _apply_theme&
# _apply_bindings& # _apply_bindings&
#
# # shellcheck disable=SC2046
# tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}')
# wait # wait
# #
# _apply_plugins # _apply_plugins
# _apply_important
#
# # shellcheck disable=SC2046
# tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}')
# } # }
# #
# _urlview() { # _urlview() {

View file

@ -354,6 +354,9 @@ tmux_conf_copy_to_os_clipboard=false
# set -g prefix C-a # set -g prefix C-a
# bind C-a send-prefix # bind C-a send-prefix
# if you don't want Oh my tmux! to alter a binding, use #!important
# bind v new-window -c #{pane_current_path} #!important
# move status line to top # move status line to top
#set -g status-position top #set -g status-position top