tmux: Use short command variants

Use short variants of commands and get rid of redundant `-T prefix` flag
to `bind`.
This commit is contained in:
2022-06-24 23:48:30 +02:00
parent 8755ade944
commit f429da3fd9

View File

@@ -6,8 +6,7 @@ set -g mode-keys vi
# 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"
bind -T copy-mode-vi MouseDragEnd1Pane send -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'
@@ -18,52 +17,52 @@ set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
# `copy-mode`)
bind -n WheelUpPane \
if -F "#{||:#{pane_in_mode},#{mouse_any_flag}}" { send -M } { copy-mode -u }
bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -XN5 scroll-up
bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -XN5 scroll-down
bind -T copy-mode-vi WheelUpPane selectp \; send -XN5 scroll-up
bind -T copy-mode-vi WheelDownPane selectp \; send -XN5 scroll-down
# Set C-a as new prefix
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set -g prefix C-a
bind C-a send-prefix
# Split panes with > and <
unbind %
bind-key < split-window -v -c "#{pane_current_path}"
bind < split-window -v -c "#{pane_current_path}"
unbind '"'
bind-key > split-window -h -c "#{pane_current_path}"
bind > split-window -h -c "#{pane_current_path}"
# Create new window in current path
bind-key -T prefix c new-window -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Resource config
bind-key -T prefix R source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" \; \
bind 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
bind F resizep -Z
# Automatically renumber windows when closing one
set -g renumber-windows on
# Enter copy-mode and scroll one page up directly with PageUp without the need
# of the prefix. (Exists already per default with prefix)
bind-key -n PPage copy-mode -u
bind -n PPage copy-mode -u
# Repeatable window-navigation bindings
bind-key -r -T prefix n next-window
bind-key -r -T prefix C-n next-window
bind-key -r -T prefix p previous-window
bind-key -r -T prefix C-p previous-window
bind -r n next
bind -r C-n next
bind -r p prev
bind -r C-p prev
# Vim-bindings
# Enter copy-mode with Escape
bind-key -T prefix Escape copy-mode
bind 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
bind -T copy-mode-vi v send -X begin-selection
# Yank into system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -selection clipboard"
bind -T copy-mode-vi y send -X copy-pipe "xclip -selection clipboard"
# Clear selection or cancel copy-mode when nothing is selected
bind -T copy-mode-vi Escape \
@@ -72,30 +71,30 @@ bind -T copy-mode-vi Escape \
# 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
unbind l
bind h selectp -L
bind j selectp -D
bind k selectp -U
bind l selectp -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
bind -n M-H resizep -L
bind -n M-J resizep -D
bind -n M-K resizep -U
bind -n M-L resizep -R
# Allow C-h to still be passed (when programs expect it as backspace, e.g. UEFI
# shell)
bind -r -T selfinsert C-h send-keys C-h
bind C-v switch-client -T selfinsert
bind -r -T selfinsert C-h send C-h
bind C-v switchc -T selfinsert
# 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
bind -n M-S-Left resizep -L
bind -n M-S-Up resizep -D
bind -n M-S-Down resizep -U
bind -n M-S-Right resizep -R
# Change installation location of plugins
set-environment -g TMUX_PLUGIN_MANAGER_PATH "$XDG_CONFIG_HOME/tmux/plugins/"
setenv -g TMUX_PLUGIN_MANAGER_PATH "$XDG_CONFIG_HOME/tmux/plugins/"
## Plugins
set -g @plugin 'tmux-plugins/tmux-continuum'
@@ -119,10 +118,10 @@ set -g @continuum-restore 'on'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
# Save sessions before detaching
unbind -T prefix d
bind-key -T prefix d {
run-shell "$XDG_CONFIG_HOME/tmux/plugins/tmux-resurrect/scripts/save.sh";
detach-client
unbind d
bind d {
run "$XDG_CONFIG_HOME/tmux/plugins/tmux-resurrect/scripts/save.sh";
detach
}
## Theming. Inspired by: