Skip to content

Instantly share code, notes, and snippets.

@Mierenga
Last active January 29, 2022 18:46
Show Gist options
  • Save Mierenga/420a34f6d7a484d3d9eb663624c3e246 to your computer and use it in GitHub Desktop.
Save Mierenga/420a34f6d7a484d3d9eb663624c3e246 to your computer and use it in GitHub Desktop.
A tmux configuration that interacts with vim splits
# reload config file
bind-key r source-file ~/.tmux.conf
# Allow scroll automatically
# set -g mouse on
# https://medium.com/free-code-camp/tmux-in-practice-scrollback-buffer-47d5ffa71c93
# trigger copy mode by with alt-up
bind -n M-Up copy-mode
bind-key J resize-pane -D 20
bind-key K resize-pane -U 20
bind-key H resize-pane -L 20
bind-key L resize-pane -R 20
bind-key j resize-pane -D 5
bind-key k resize-pane -U 5
bind-key h resize-pane -L 5
bind-key l resize-pane -R 5
# 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"
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
# Status Bar solarized-dark (default)
set-option -g status-bg black
set-option -g pane-active-border-fg yellow
set-option -g pane-border-fg cyan
# recolor the active pane
set -g window-style 'fg=white,bg=colour232'
set -g window-active-style 'fg=white,bg=colour235'
#set -g pane-active-border-bg 'colour17'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment