Skip to content

Instantly share code, notes, and snippets.

@artronics
Created February 2, 2022 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artronics/2c3582ace7155a53ab3574d4c833edba to your computer and use it in GitHub Desktop.
Save artronics/2c3582ace7155a53ab3574d4c833edba to your computer and use it in GitHub Desktop.
# Set prefix to Ctrl-Space instead of Ctrl-b
unbind C-b
set -g prefix C-a
bind a send-prefix
# See (and comments): https://stackoverflow.com/a/42461580/3943054
bind -n S-Enter send-keys Escape "[13;2u"
bind -n C-Enter send-keys Escape "[13;5u"
# split panes using | and _
bind | split-window -h
bind _ split-window -v
unbind '"'
unbind %
bind q killp
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi V send -X select-line
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
# switch panes using Alt-arrow without prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(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"
set -g mouse on
set-option -gw xterm-keys on
bind C-Tab next-window
bind C-S-Tab previous-window
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 0
# increase scrollback buffer size
set -g history-limit 50000
# tmux messages are displayed for 4 seconds
set -g display-time 2000
# upgrade $TERM
set -g default-terminal "screen-256color"
# focus events enabled for terminals that support them
set -g focus-events on
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment