Skip to content

Instantly share code, notes, and snippets.

@malandro-sv
Last active September 4, 2020 17:52
Show Gist options
  • Select an option

  • Save malandro-sv/ecc856ad2ae6f92c914c1f859995e11a to your computer and use it in GitHub Desktop.

Select an option

Save malandro-sv/ecc856ad2ae6f92c914c1f859995e11a to your computer and use it in GitHub Desktop.
# GistID: ecc856ad2ae6f92c914c1f859995e11a
set -g default-terminal "screen-256color"
set -g status-bg colour232
set -g status-fg colour9
# set -g mode-mouse on
# Chris Toomey's 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-g' if-shell "$is_vim" 'send-keys C-g' 'select-pane -R'
# bind-key -n 'C-g' if-shell "$is_vim" 'send-keys C-g' '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-g' select-pane -R
# bind-key -T copy-mode-vi 'C-g' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# tmux pane creation:
# split panes using | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
unbind Tab
# keep C-l to clear screen:
bind C-l send-keys 'C-l'
# reload tmux.conf on the go:
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf RELOADED."
# these two are for tmux =< v2.3:
# bind-key -t vi-copy 'v' begin-selection
# bind-key -t vi-copy 'y' begin-selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment