From a83185a398e8b8aa0b2b0883b84fb5e038ef691d Mon Sep 17 00:00:00 2001 From: David Ibia Date: Tue, 1 Oct 2024 15:06:18 +0100 Subject: [PATCH] chore(.tmux.conf): update terminal-features setting to 'XXX:RGB' for tmux configuration chore(.tmux.conf): remove christoomey/vim-tmux-navigator plugin from plugin list feat(.tmux.conf): add key bindings for VIM navigation in tmux feat(.tmux.conf): add conditional key bindings based on tmux version for VIM navigation feat(.tmux.conf): add key bindings for VIM navigation in copy-mode-vi feat(.tmux.conf): add comments for VIM and TMUX Navigation sections in tmux.conf --- .tmux.conf | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 737602c..d47e21c 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,6 +1,6 @@ set -g mouse on bind r source-file ~/.tmux.conf -set-option -sa terminal-features ',xterm-kitty:RGB' +set-option -a terminal-features 'XXX:RGB' set-option -sg escape-time 10 set-option -g focus-events on set-window-option -g mode-keys vi @@ -52,7 +52,6 @@ bind -r m resize-pane -Z # List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' -set -g @plugin 'christoomey/vim-tmux-navigator' set -g @plugin 'MunifTanjim/tmux-mode-indicator' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-continuum' @@ -90,15 +89,32 @@ set -g @catppuccin_date_time_text "%H:%M" # for neovim set -g @resurrect-strategy-nvim 'session' set -g @continuum-restore 'on' -# -# set-window-option -g window-status-current-format '#[fg=red,bold]#[bg=default] #I #W #[fg=blue,bg=default]' -# set-window-option -g window-status-format '#[fg=#ffffff,bold]#[bg=default] #I #W #[fg=default,bg=default]' -# -# -# set -g status-left-length 20 -# set -g status-position top -# set -g status-justify left -# set -g status-style bg=default + +# Is VIM? +# TMUX Navigation + +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf|pipenv)(diff)?$'" +bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L' +bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D' +bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U' +bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R' + +tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")' + +if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'" + +if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \ + "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'" + +bind-key -T copy-mode-vi 'C-h' select-pane -L +bind-key -T copy-mode-vi 'C-j' select-pane -D +bind-key -T copy-mode-vi 'C-k' select-pane -U +bind-key -T copy-mode-vi 'C-l' select-pane -R +bind-key -T copy-mode-vi 'C-\' select-pane -l + + # # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm'