Skip to content

Instantly share code, notes, and snippets.

@xPMo
Created January 28, 2018 21:56
Show Gist options
  • Save xPMo/d239ecbed9d336a0644f0bd53fa69870 to your computer and use it in GitHub Desktop.
Save xPMo/d239ecbed9d336a0644f0bd53fa69870 to your computer and use it in GitHub Desktop.
# change prefix to Alt+a
unbind-key C-b
set -g prefix 'M-a'
bind-key 'M-a' send-prefix
# escape time of 50 ms
set -sg escape-time 50
set -g default-terminal "screen-256color"
# Version-specific commands [grumble, grumble]
# See: https://github.com/tmux/tmux/blob/master/CHANGES
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.1" | bc)" = 1 ]' \
"set -g mouse-select-pane on; set -g mode-mouse on; \
set -g mouse-resize-pane on; set -g mouse-select-window on"
# In version 2.1 "mouse" replaced the previous 4 mouse options
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' \
"set -g mouse on"
# UTF8 is autodetected in 2.2 onwards, but errors if explicitly set
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.2" | bc)" = 1 ]' \
"set -g utf8 on; set -g status-utf8 on; set -g mouse-utf8 on"
# copy mode < 2.4
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
"bind-key -t vi-copy p paste-buffer; \
bind-key -t vi-copy y copy-selection"
# In version 2.4, key mode tables were changed
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = ]' \
"bind-key -T copy-mode-vi p paste-buffer; \
bind-key -T copy-mode-vi y send-keys -X copy-selection"
set-window-option -g mode-keys vi
# hjkl pane traversal
# > w/prefix
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# > prefixless --
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# HJKL pane resize
# > w/prefix
bind H resize-pane -L
bind J resize-pane -D
bind K resize-pane -U
bind L resize-pane -R
# > prefixless --
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
setw -g aggressive-resize on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment