about summary refs log tree commit diff
path: root/dotfiles
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-04-07 19:12:06 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-04-07 19:12:37 +0200
commit2d24894ead376a712c25a66c57c5245d7c8d7001 (patch)
treebdcd752c982c3796b566f15039ef098f42f19ad2 /dotfiles
parentDotfiles: Alacritty: Set copy paste keybinds (diff)
downloadnixos-config-2d24894ead376a712c25a66c57c5245d7c8d7001.tar.gz
nixos-config-2d24894ead376a712c25a66c57c5245d7c8d7001.tar.bz2
nixos-config-2d24894ead376a712c25a66c57c5245d7c8d7001.zip
Dotfiles: Tmux: Fix nvim-tmux window switching for nixos
Diffstat (limited to 'dotfiles')
-rw-r--r--dotfiles/tmux.conf20
1 files changed, 19 insertions, 1 deletions
diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf
index 8b733a7..6662ba4 100644
--- a/dotfiles/tmux.conf
+++ b/dotfiles/tmux.conf
@@ -46,6 +46,25 @@ bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
 bind '"' split-window -v -c "#{pane_current_path}"
 bind % split-window -h -c "#{pane_current_path}"
 
+# Smart pane switching with awareness of Vim splits.
+# See: https://github.com/christoomey/vim-tmux-navigator
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE 'n?vim?x?'" # This is changed from the default due to it not working on Nix; see https://github.com/christoomey/vim-tmux-navigator/issues/195
+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
+
 resurrect_dir="$HOME/.tmux/resurrect"
 set -g @resurrect-dir $resurrect_dir
 set -g @resurrect-capture-pane-contents 'on'
@@ -62,7 +81,6 @@ set -g @yank_selection 'primary'
 
 set -g @plugin 'tmux-plugins/tpm'
 set -g @plugin 'tmux-plugins/tmux-sensible'
-set -g @plugin 'christoomey/vim-tmux-navigator'
 set -g @plugin 'catppuccin/tmux'
 set -g @plugin 'baitinq/tmux-yank' #has https://github.com/tmux-plugins/tmux-yank/pull/177
 set -g @plugin 'tmux-plugins/tmux-resurrect'