dotfiles/.config/tmux/conf/binds.conf

65 lines
2.3 KiB
Text

# Set new prefix (Alt+Space)
unbind C-b
set -g prefix M-Space
bind Space send-prefix
# Config reload
bind-key -n R source-file ~/.config/tmux/tmux.conf \; display-message "tmux.conf reloaded"
# Vim mode
setw -g mode-keys vi
set -g status-keys vi
# Split windows
bind | split-window -hc "#{pane_current_path}"
bind-key "\\" split-window -fh -c "#{pane_current_path}"
bind - split-window -vc "#{pane_current_path}"
# Maintain the same path when creating a new window
bind c new-window -c "#{pane_current_path}"
bind-key C command-prompt -p "Name of new window: " "new-window -c '#{pane_current_path}' -n '%%'"
# Move to the next and prev window
bind-key l next-window
bind-key h previous-window
# Change window name
bind-key r command-prompt -I "#W" "rename-window '%%'"
# Move to the next and prev session
bind j switch-client -n
bind k switch-client -p
# Close a window
bind-key Q confirm-before kill-window
# Close a pane
bind-key q confirm-before kill-pane
# Swap windows
bind -r "<" swap-window -d -t -1
bind -r ">" swap-window -d -t +1
# Smart pane switching with awareness of Neovim splits.
bind-key -n C-h if -F "#{@pane-is-vim}" 'send-keys C-h' 'select-pane -L'
bind-key -n C-j if -F "#{@pane-is-vim}" 'send-keys C-j' 'select-pane -D'
bind-key -n C-k if -F "#{@pane-is-vim}" 'send-keys C-k' 'select-pane -U'
bind-key -n C-l if -F "#{@pane-is-vim}" 'send-keys C-l' 'select-pane -R'
# Smart pane resizing with awareness of Neovim splits.
bind-key -n C-left if -F "#{@pane-is-vim}" 'send-keys C-left' 'resize-pane -L 3'
bind-key -n C-down if -F "#{@pane-is-vim}" 'send-keys C-down' 'resize-pane -D 3'
bind-key -n C-up if -F "#{@pane-is-vim}" 'send-keys C-up' 'resize-pane -U 3'
bind-key -n C-right if -F "#{@pane-is-vim}" 'send-keys C-right' 'resize-pane -R 3'
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 -F \"#{@pane-is-vim}\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if -F \"#{@pane-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