summaryrefslogtreecommitdiff
path: root/config/common/tmux/tmux.conf
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-23 14:04:53 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-23 14:04:53 +0200
commite9f0509e71ba79fb92bb55933d19b63d2fd11ef4 (patch)
treeddd152ade759d2a8ff4788ebec851951d2131ea3 /config/common/tmux/tmux.conf
parent2993a95e1f6f11ac463a1befb23be17bdcf4ec28 (diff)
use vim-tmux-navigator plugin
Diffstat (limited to 'config/common/tmux/tmux.conf')
-rwxr-xr-xconfig/common/tmux/tmux.conf32
1 files changed, 27 insertions, 5 deletions
diff --git a/config/common/tmux/tmux.conf b/config/common/tmux/tmux.conf
index 45166c0..5867a92 100755
--- a/config/common/tmux/tmux.conf
+++ b/config/common/tmux/tmux.conf
@@ -62,12 +62,34 @@ bind J command-prompt -1p "Send to window:" "join-pane -t \:%% ; select-window -
bind b break-pane -t :
# Reset length and shit
bind z select-layout main-vertical
+
+
+
+
# Pane navigating with h|j|k|l a la vim
-bind -n -N "select leftwards pane" M-h select-pane -L
-bind -n -N "select downwards pane" M-j select-pane -D
-bind -n -N "select upwards pane" M-k select-pane -U
-bind -n -N "select rightwards pane" M-l select-pane -R
-# Window navigating with M-u|i
+# 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 '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(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'
+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 '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-\' select-pane -l
+
+
+
+
bind -n M-u previous-window
bind -n M-i next-window
# Session navigeting with S-M-u|i