Skip to content

Instantly share code, notes, and snippets.

@tompretty
Last active June 17, 2020 12:24
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 tompretty/1b1c2c6ce4e95820b90376898c174961 to your computer and use it in GitHub Desktop.
Save tompretty/1b1c2c6ce4e95820b90376898c174961 to your computer and use it in GitHub Desktop.
tmux config
# prefix
unbind C-b
set -g prefix C-s
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
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'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind -n S-left resize-pane -L 2
bind -n S-right resize-pane -R 2
bind -n S-up resize-pane -U 2
bind -n S-down resize-pane -D 2
bind -n C-left resize-pane -L 10
bind -n C-right resize-pane -R 10
bind -n C-up resize-pane -U 5
bind -n C-down resize-pane -D 5
# windows
bind-key \\ split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind b break-pane -d
# sessions
bind C-j choose-tree
# config
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# options
set -g escape-time 0
set -g default-terminal "xterm-256color"
set -g status-bg '#666666'
set -g status-fg '#aaaaaa'
set -g status-left-length 50
set -g status-right "#(battery -t) #(date '+%a, %b %d - %I:%M')"
set -g renumber-windows on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment