nvim: add tmux integration

This commit is contained in:
2025-03-22 13:01:55 +01:00
parent 48664abc41
commit b6bc1de7af
3 changed files with 62 additions and 9 deletions

View File

@ -3,15 +3,6 @@ set -g status-fg colour7
set -sg escape-time 0
bind-key -n M-j select-pane -D
bind-key -n M-k select-pane -U
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
bind-key -n M-J switch-client -n
bind-key -n M-K switch-client -p
bind-key -n M-H previous-window
bind-key -n M-L next-window
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
@ -56,3 +47,39 @@ set -g status-left " #[fg=green]#[bg=green]#[fg=black] #H #[bg=default]#[fg=g
set -g status-left-length 50
set -g status-right "#[fg=green]#[bg=green]#[fg=black] %H:%M #[bg=default]#[fg=green] "
set-window-option -g window-status-current-format '#[fg=green]#[bg=green]#[fg=black] #I:#W#F #[fg=green]#[bg=black]'
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'"
bind-key -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'select-pane -R'
bind-key -n 'M-n' if-shell "$is_vim" 'send-keys M-n' 'select-window -n'
bind-key -n 'M-p' if-shell "$is_vim" 'send-keys M-p' 'select-window -p'
bind-key -T copy-mode-vi 'M-h' select-pane -L
bind-key -T copy-mode-vi 'M-j' select-pane -D
bind-key -T copy-mode-vi 'M-k' select-pane -U
bind-key -T copy-mode-vi 'M-l' select-pane -R
bind-key -T copy-mode-vi 'M-n' select-window -n
bind-key -T copy-mode-vi 'M-p' select-window -p
bind -n 'M-H' if-shell "$is_vim" 'send-keys M-H' 'resize-pane -L 1'
bind -n 'M-J' if-shell "$is_vim" 'send-keys M-J' 'resize-pane -D 1'
bind -n 'M-K' if-shell "$is_vim" 'send-keys M-K' 'resize-pane -U 1'
bind -n 'M-L' if-shell "$is_vim" 'send-keys M-L' 'resize-pane -R 1'
bind-key -T copy-mode-vi M-H resize-pane -L 1
bind-key -T copy-mode-vi M-J resize-pane -D 1
bind-key -T copy-mode-vi M-K resize-pane -U 1
bind-key -T copy-mode-vi M-L resize-pane -R 1
bind -n 'C-M-h' if-shell "$is_vim" 'send-keys C-M-h' 'swap-pane -s "{left-of}"'
bind -n 'C-M-j' if-shell "$is_vim" 'send-keys C-M-j' 'swap-pane -s "{down-of}"'
bind -n 'C-M-k' if-shell "$is_vim" 'send-keys C-M-k' 'swap-pane -s "{up-of}"'
bind -n 'C-M-l' if-shell "$is_vim" 'send-keys C-M-l' 'swap-pane -s "{right-of}"'
bind-key -T copy-mode-vi C-M-h swap-pane -s "{left-of}"
bind-key -T copy-mode-vi C-M-j swap-pane -s "{down-of}"
bind-key -T copy-mode-vi C-M-k swap-pane -s "{up-of}"
bind-key -T copy-mode-vi C-M-l swap-pane -s "{right-of}"