Skip to content

Instantly share code, notes, and snippets.

Last active November 10, 2022 14:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# Set prefix to Ctrl-Space instead of Ctrl-b
unbind C-b
set -g prefix C-n
bind n send-prefix
# See (and comments):
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 ˙ select-pane -L
bind -n ¬ select-pane -R
bind -n ˚ select-pane -U
bind -n ∆ 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"
# Smart pane switching with awareness of vim and fzf
should_forward="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?($forward_programs)(diff)?$'"
bind -n C-h if-shell "$should_forward" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$should_forward" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$should_forward" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$should_forward" "send-keys C-l" "select-pane -R"
bind -n C-\\ if-shell "$should_forward" "send-keys C-\\" "select-pane -l"
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 (
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