Files
dotfiles/.config/tmux/tmux.conf
Julian Prein 4cf0eedd56 vim,tmux:plugs: Add vim-tmux-navigator
[vim-tmux-navigator][1]:

> Seamless navigation between tmux panes and vim splits

Add the hybrid vim/tmux plugin `vim-tmux-navigator` to switch between
tmux panes and vim splits with `C-[hjkl]`.

Add vim-tmux-navigator as a submodule in tmux/plugins and create a
symlink from vim/pack/plugins/start.

Get rid of similar switching keymappings in the vim and tmux configs.

[1]: https://github.com/christoomey/vim-tmux-navigator
2022-06-23 23:58:46 +02:00

115 lines
3.8 KiB
Bash

set -g default-terminal "tmux-256color"
set -g mouse on
set -g mode-keys vi
# Better clipboard on mousedrag (https://unix.stackexchange.com/a/349020)
# Disable xterm escape sequences for setting clipboard
set -s set-clipboard off
# Copy selection into primary selection (without aborting)
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "xclip -se p"
# https://github.com/neovim/neovim/wiki/FAQ#cursor-shape-doesnt-change-in-tmux
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
# Set C-a as new prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Split panes with > and <
unbind %
bind-key < split-window -v -c "#{pane_current_path}"
unbind '"'
bind-key > split-window -h -c "#{pane_current_path}"
# Create new window in current path
bind-key -T prefix c new-window -c "#{pane_current_path}"
# Resource config
bind-key -T prefix R source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" \; display-message "Sourced $XDG_CONFIG_HOME/tmux/tmux.conf"
# Fullscreen pane (toggle)
bind-key -T prefix F resize-pane -Z
# Automatically renumber windows when closing one
set -g renumber-windows on
# Vim-bindings
# Enter copy-mode with Escape
bind-key -T prefix Escape copy-mode
# Start selection (e.g. visual mode) with `v`
unbind -T copy-mode-vi v
bind-key -T copy-mode-vi v send-keys -X begin-selection
# Yank into system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -selection clipboard"
# Navigate panes with <prefix>-[hjkl]
# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes
# See vim-tmux-navigator
unbind -T prefix l
bind -T prefix h select-pane -L
bind -T prefix j select-pane -D
bind -T prefix k select-pane -U
bind -T prefix l select-pane -R
# Resize panes with Alt-Shift-[hjkl]
bind -n M-H resize-pane -L
bind -n M-J resize-pane -D
bind -n M-K resize-pane -U
bind -n M-L resize-pane -R
# Resize panes with Alt-Shift-<arrow>
bind -n M-S-Left resize-pane -L
bind -n M-S-Up resize-pane -D
bind -n M-S-Down resize-pane -U
bind -n M-S-Right resize-pane -R
# Change installation location of plugins
set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.config/tmux/plugins/'
## Plugins
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'vim-tmux-navigator'
# Capture pane content
set -g @resurrect-capture-pane-contents 'on'
# Change keybindings
set -g @resurrect-save 'C-s'
set -g @resurrect-restore 'C-r'
# Save session every 5 min
set -g @continuum-save-interval '5'
# Last saved environment is automatically restored when tmux is started.
set -g @continuum-restore 'on'
# Restore {,neo}vim sessions with the help of vim-obsession
# https://github.com/tpope/vim-obsession
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
## Theming (inspired by https://github.com/Who23/dots/blob/21976e76644d8d9261ebdcf61733d2181a1612eb/tmux.conf)
set -g status-style bg=default,fg=white
set -g message-command-style bg=default,fg=brightyellow
set -g message-style bg=brightyellow,fg=black
set -g mode-style bg=brightyellow,fg=black
set -g pane-border-style bg=default,fg=brightblack
set -g pane-active-border-style bg=default,fg=brightyellow
# Display prefix when pressed
set -g @prefix_highlight_fg 'black'
set -g @prefix_highlight_bg 'brightyellow'
set -g @prefix_highlight_output_prefix ' '
set -g @prefix_highlight_output_suffix ' '
set -g status-right "#{prefix_highlight}"
set -g status-left "#{prefix_highlight}"
set -g status-justify centre
set -g window-status-current-format "#[fg=brightyellow bold]#I #W"
set -g window-status-format "#[fg=brightblack]#I #W"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.config/tmux/plugins/tpm/tpm'