aboutsummaryrefslogtreecommitdiff
path: root/.config/tmux/tmux.conf
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-06-22 19:19:34 +0200
committersrdusr <trevorgray@srdusr.com>2023-06-22 19:19:34 +0200
commit846bb041f32c3905ff93f5fa5648ecfd865f2034 (patch)
treefe42ef7a22dfa30a48aacd4f7db8045d5cc338ee /.config/tmux/tmux.conf
parent59f43ab346c30619943df233555d93e58a6e09bd (diff)
downloaddotfiles-846bb041f32c3905ff93f5fa5648ecfd865f2034.tar.gz
dotfiles-846bb041f32c3905ff93f5fa5648ecfd865f2034.zip
Made moving between panes conditional dependent on whether remote/local
Diffstat (limited to '.config/tmux/tmux.conf')
-rw-r--r--.config/tmux/tmux.conf49
1 files changed, 36 insertions, 13 deletions
diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf
index 5d6a5e5..bdefdd2 100644
--- a/.config/tmux/tmux.conf
+++ b/.config/tmux/tmux.conf
@@ -94,24 +94,47 @@ bind -n M-0 select-window -t :=0
# 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?)(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'
+#is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(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'"
+#
+## Copy Mode vi-directional keys
+#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
+
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'"
+
+# Key binding for navigating between panes in the outer tmux session
+bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'if-shell -F "#{pane_in_nested}" "select-pane -L" "select-pane -L; select-window -t =%"'
+
+bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'if-shell -F "#{pane_in_nested}" "select-pane -D" "select-pane -D; select-window -t =%"'
+bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'if-shell -F "#{pane_in_nested}" "select-pane -U" "select-pane -U; select-window -t =%"'
+bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'if-shell -F "#{pane_in_nested}" "select-pane -R" "select-pane -R; select-window -t =%"'
+
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'"
+ "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'if-shell -F \"#{pane_in_nested}\" \"select-pane -l\" \"select-pane -l; select-window -t =%\"'"
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 -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'if-shell -F \"#{pane_in_nested}\" \"select-pane -l\" \"select-pane -l; select-window -t =%\"'"
# Copy Mode vi-directional keys
-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
+bind-key -T copy-mode-vi 'C-h' if-shell -F "#{pane_in_nested}" "select-pane -L" "select-pane -L; select-window -t =%"
+bind-key -T copy-mode-vi 'C-j' if-shell -F "#{pane_in_nested}" "select-pane -D" "select-pane -D; select-window -t =%"
+bind-key -T copy-mode-vi 'C-k' if-shell -F "#{pane_in_nested}" "select-pane -U" "select-pane -U; select-window -t =%"
+bind-key -T copy-mode-vi 'C-l' if-shell -F "#{pane_in_nested}" "select-pane -R" "select-pane -R; select-window -t =%"
+#bind-key -T copy-mode-vi 'C-\\' if-shell -F "#{pane_in_nested}" "select-pane -l" "select-pane -l; select-window -t =%"
# Change horizontal split <Prefix>% and Vertical split <Prefix>" to <Prefix>h and <Prefix>v respectively and change current working directory
bind v split-window -h -c "#{pane_current_path}"