Skip to content

Instantly share code, notes, and snippets.

@bufordtaylor
Created October 21, 2019 20:56
Show Gist options
  • Save bufordtaylor/ef3046a21e808e690e04a33486362ef2 to your computer and use it in GitHub Desktop.
Save bufordtaylor/ef3046a21e808e690e04a33486362ef2 to your computer and use it in GitHub Desktop.
set-option -g base-index 1 # Start window index count at 1 instead of 0
set -g history-limit 500000 # Set the history limit higher
set -s escape-time 0 # Allows for faster key repetition
setw -g aggressive-resize on # Don't constrain window size to smallest client if they're on another window
set -g focus-events on # Send focus events to vim
# setw -g monitor-activity on # Highlight window name when their is activity
set -g mouse on # Enable mouse mode: scrolling, pane selecting and window selecting
# Use 256 colors; needed for lightline.vim
set -g default-terminal "screen-256color"
# Restore "open new pane/window in current directory" functionality
bind -n M-c new-window -c "#{pane_current_path}"
# Use v and s to split the window up
bind -n M-v split-window -h -c "#{pane_current_path}"
bind -n M-s split-window -v -c "#{pane_current_path}"
# Option+z to zoom
bind -n M-z resize-pane -Z
# use vim keys while in copy mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"
# Switch windows via Option+number
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9
# use Option+h|j|k|l to move between panes unless in vim (so that vim can handle moving around)
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L"
bind -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D"
bind -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U"
bind -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R"
# Use capital vim motion keys for resizing
bind -n M-J resize-pane -D
bind -n M-K resize-pane -U
bind -n M-H resize-pane -L
bind -n M-L resize-pane -R
# Send literal Option+Arrow/h|j|k|l|z|etc
bind M-h send-keys 'M-H'
bind M-j send-keys 'M-J'
bind M-k send-keys 'M-K'
bind M-l send-keys 'M-L'
bind M-h send-keys 'M-h'
bind M-j send-keys 'M-j'
bind M-k send-keys 'M-k'
bind M-l send-keys 'M-l'
bind M-z send-keys 'M-z'
bind M-c send-keys 'M-c'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment