Advertisement
TheChetan

tmux.conf

Feb 10th, 2022 (edited)
2,927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set -g default-terminal "xterm-256color"
  2.  
  3. unbind C-b
  4. set-option -g prefix C-a
  5. bind-key C-a send-prefix
  6.  
  7. # Setup 'v' to begin selection as in Vim
  8. bind-key -T copy-mode-vi v send -X begin-selection
  9. bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
  10. setw -g mode-keys vi
  11.  
  12. # Smart pane switching with awareness of Vim splits.
  13. # See: https://github.com/christoomey/vim-tmux-navigator
  14. is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
  15.    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
  16. bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
  17. bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
  18. bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
  19. bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
  20. tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
  21. if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
  22.     "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
  23. if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
  24.     "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"
  25.  
  26. bind-key -T copy-mode-vi 'C-h' select-pane -L
  27. bind-key -T copy-mode-vi 'C-j' select-pane -D
  28. bind-key -T copy-mode-vi 'C-k' select-pane -U
  29. bind-key -T copy-mode-vi 'C-l' select-pane -R
  30. bind-key -T copy-mode-vi 'C-\' select-pane -l
  31.  
  32.  
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement