diff --git a/config/.tmux.conf b/config/.tmux.conf index 921d5fc..b608644 100644 --- a/config/.tmux.conf +++ b/config/.tmux.conf @@ -68,10 +68,8 @@ bind C-f command-prompt -p find-session 'switch-client -t %%' # session navigation bind BTab switch-client -l # move to last session -# split current window horizontally -bind - split-window -v -# split current window vertically -bind _ split-window -h +bind _ split-window -v +bind - split-window -h # pane navigation bind -r h select-pane -L # move left diff --git a/config/.tmux.conf.local b/config/.tmux.conf.local index 01fa27a..fb3bfec 100644 --- a/config/.tmux.conf.local +++ b/config/.tmux.conf.local @@ -20,7 +20,7 @@ tmux_conf_new_session_prompt=false # - true # - false (default) # - disabled (do not modify new-window bindings) -tmux_conf_new_window_retain_current_path=false +tmux_conf_new_window_retain_current_path=true # new window tries to reconnect ssh sessions, possible values are: # - true @@ -163,7 +163,7 @@ tmux_conf_theme_status_attr="none" # - #{hostname_full_ssh} # - #{username} # - #{username_ssh} -tmux_conf_theme_terminal_title="#h ❐ #S ● #I #W" +tmux_conf_theme_terminal_title='#{hostname} | #{circled_session_name} | #W' # window status style # - built-in variables are: @@ -445,3 +445,24 @@ tmux_conf_uninstall_plugins_on_reload=true # # "$@" # # /!\ do not remove the previous line + + +# 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 '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