diff dot_tmux.conf @ 348:f220567b278e

Update tmux-vim mapping
author Zeger Van de Vannet <zegervdv@me.com>
date Thu, 04 Feb 2021 18:28:57 +0100
parents 88d7010b5694
children 44442a6b8aa6
line wrap: on
line diff
--- a/dot_tmux.conf	Fri Feb 05 14:58:49 2021 +0100
+++ b/dot_tmux.conf	Thu Feb 04 18:28:57 2021 +0100
@@ -2,13 +2,13 @@
 
 # Nested TMUX sessions (from
 # https://medium.freecodecamp.org/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795)
-bind -T root F12 \
+bind -T root F11 \
         set prefix None \;\
         set key-table off \;\
         set status-right "#[fg=colour0,bg=colour1] DISABLED #[fg=colour3,bg=colour0] #{session_name}#[fg=colour1] | #[fg=colour2]%d %b %l:%M %p "
         refresh-client -S \;\
 
-bind -T off F12 \
+bind -T off F11 \
         set -u prefix \;\
         set -u key-table \;\
         set -u status-right \;\
@@ -35,8 +35,8 @@
 set -g status-justify "left"
 set -g status-bg "colour0"
 set -g status-fg "colour7"
-set -g message-bg "colour0"
-set -g message-fg "colour8"
+# set -g message-bg "colour0"
+# set -g message-fg "colour8"
 
 setw -g window-status-bell-style "fg=colour0,bg=colour5"
 
@@ -67,16 +67,21 @@
 # See: https://github.com/christoomey/vim-tmux-navigator
 is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
     | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|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"
-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
+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
 #act like GNU screen
 unbind C-b
 set -g prefix C-Space