From 18a111ff93aaaeb18ea94667d749d90aa26ec81d Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Thu, 14 Jul 2022 17:29:15 +0200 Subject: [PATCH] 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 --- .tmux.conf | 41 ++++++++++++++++++++++++++--------------- .tmux.conf.local | 3 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 53d0bc6..6f6ff7c 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -165,13 +165,9 @@ bind p paste-buffer # paste from the top paste buffer bind P choose-buffer # choose which buffer to paste from -# -- user defined overrides ---------------------------------------------------- - -source -q ~/.tmux.conf.local - - # -- 8< ------------------------------------------------------------------------ +source -q ~/.tmux.conf.local 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 "$@" # } # -# _apply_overrides() { +# _apply_24b() { # tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-auto} # tmux_conf_24b_colour=${tmux_conf_24b_colour:-$tmux_conf_theme_24b_colour} # if [ x"$tmux_conf_24b_colour" = x"auto" ]; then # case "$COLORTERM" in # truecolor|24bit) -# apply_overrides=true +# apply_24b=true # ;; # esac -# if [ x"$apply_overrides" = x"" ] && [ x"$(tput colors)" = x"16777216" ]; then -# apply_overrides=true +# if [ x"$apply_24b" = x"" ] && [ x"$(tput colors)" = x"16777216" ]; then +# apply_24b=true # fi # elif _is_true "$tmux_conf_24b_colour"; then -# apply_overrides=true +# apply_24b=true # fi -# if [ x"$apply_overrides" = x"true" ]; then +# if [ x"$apply_24b" = x"true" ]; then # case "$TERM" in # 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\"" # } # +# _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() { # # 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 # -# _apply_overrides +# _apply_24b # _apply_theme& # _apply_bindings& -# -# # shellcheck disable=SC2046 -# tmux setenv -gu tmux_conf_dummy $(printenv | grep -E -o '^tmux_conf_[^=]+' | awk '{printf "; setenv -gu %s", $0}') # wait # # _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() { diff --git a/.tmux.conf.local b/.tmux.conf.local index 76065ec..4bc6c83 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -354,6 +354,9 @@ tmux_conf_copy_to_os_clipboard=false # set -g prefix C-a # 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 #set -g status-position top