✨ feat(tmux): Make tmux pane switching smarter
This commit is contained in:
parent
49071f2a7f
commit
469f5bf953
2 changed files with 41 additions and 6 deletions
|
@ -67,4 +67,22 @@ return {
|
|||
"kdheepak/lazygit.nvim",
|
||||
cmd = "LazyGit",
|
||||
},
|
||||
|
||||
{
|
||||
"christoomey/vim-tmux-navigator",
|
||||
cmd = {
|
||||
"TmuxNavigateLeft",
|
||||
"TmuxNavigateDown",
|
||||
"TmuxNavigateUp",
|
||||
"TmuxNavigateRight",
|
||||
"TmuxNavigatePrevious",
|
||||
},
|
||||
keys = {
|
||||
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
|
||||
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
|
||||
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
|
||||
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
|
||||
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
29
.tmux.conf
29
.tmux.conf
|
@ -5,6 +5,7 @@
|
|||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||
set -g @plugin 'catppuccin/tmux'
|
||||
|
||||
################################################################################
|
||||
|
@ -26,6 +27,9 @@ set -g renumber-windows on
|
|||
set -g default-terminal "tmux-256color"
|
||||
set -ag terminal-overrides ",*:RGB"
|
||||
|
||||
set -g @continuum-boot 'on'
|
||||
set -g @continuum-restore 'on'
|
||||
|
||||
################################################################################
|
||||
# Key Mappings #
|
||||
################################################################################
|
||||
|
@ -45,11 +49,20 @@ bind -N 'hsplit' - split-window -v -c "#{pane_current_path}"
|
|||
unbind '"'
|
||||
unbind %
|
||||
|
||||
# Vi-like pane switching.
|
||||
bind -N 'Switch to pane (left)' h select-pane -L
|
||||
bind -N 'Switch to pane (down)' j select-pane -D
|
||||
bind -N 'Switch to pane (up)' k select-pane -U
|
||||
bind -N 'Switch to pane (right)' l select-pane -R
|
||||
# Smart pane switching with awareness of vim/fzf.
|
||||
IS_VIM="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
|
||||
IS_FZF="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'"
|
||||
|
||||
bind -n -N 'Switch to pane (left)' C-h if-shell "${IS_VIM} || ${IS_FZF}" 'send C-h' 'select-pane -L'
|
||||
bind -n -N 'Switch to pane (down)' C-j if-shell "${IS_VIM} || ${IS_FZF}" 'send C-j' 'select-pane -D'
|
||||
bind -n -N 'Switch to pane (up)' C-k if-shell "${IS_VIM} || ${IS_FZF}" 'send C-k' 'select-pane -U'
|
||||
bind -n -N 'Switch to pane (right)' C-l if-shell "${IS_VIM} || ${IS_FZF}" 'send C-l' 'select-pane -R'
|
||||
|
||||
# Copy-mode.
|
||||
bind -T copy-mode-vi -N 'Copy mode: switch to pane (left)' C-h if-shell "${IS_VIM} || ${IS_FZF}" 'send C-h' 'select-pane -L'
|
||||
bind -T copy-mode-vi -N 'Copy mode: Switch to pane (down)' C-j if-shell "${IS_VIM} || ${IS_FZF}" 'send C-j' 'select-pane -D'
|
||||
bind -T copy-mode-vn -N 'Copy mode: Switch to pane (up)' C-k if-shell "${IS_VIM} || ${IS_FZF}" 'send C-k' 'select-pane -U'
|
||||
bind -T copy-mode-vn -N 'Copy mode: Switch to pane (right)' C-l if-shell "${IS_VIM} || ${IS_FZF}" 'send C-l' 'select-pane -R'
|
||||
|
||||
# Vi-like resizing.
|
||||
bind -r -N 'Resize pane (left)' M-h resize-pane -L 5
|
||||
|
@ -91,7 +104,11 @@ unbind p
|
|||
bind p paste-buffer
|
||||
|
||||
bind -T copy-mode-vi v send -X begin-selection
|
||||
bind -T copy-mode-vi y send -X copy-selection-and-cancel
|
||||
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'copyq copy -'
|
||||
bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1'
|
||||
bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1'
|
||||
bind -T copy-mode-vi q send -X cancel
|
||||
bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel'
|
||||
|
||||
################################################################################
|
||||
# Catppuccin #
|
||||
|
|
Loading…
Reference in a new issue