Skip to content

Instantly share code, notes, and snippets.

@cryptojuice
Created August 22, 2017 21:47
Show Gist options
  • Save cryptojuice/715c6923df741eeb826cedb8697603ce to your computer and use it in GitHub Desktop.
Save cryptojuice/715c6923df741eeb826cedb8697603ce to your computer and use it in GitHub Desktop.
set -g default-terminal "screen-256color"
set -g history-limit 10000
# use VI
set-window-option -g mode-keys vi
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# y and p as in vim
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
bind -t vi-copy 'Space' halfpage-down
bind -t vi-copy 'Bspace' halfpage-up
# moving between panes with vim movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
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
# resize panes with vim movement keys
# bind -r H resize-pane -L 5
# bind -r J resize-pane -D 5
# bind -r K resize-pane -U 5
# bind -r L resize-pane -R 5
bind-key -nr M-Up resize-pane -U
bind-key -nr M-Down resize-pane -D
bind-key -nr M-Left resize-pane -L
bind-key -nr M-Right resize-pane -R
# move between windows with vim movement keys
# bind -r C-h select-window -t :-
# bind -r C-l select-window -t :+
# use ctrl-e instead of ctrl-b
set -g prefix C-e
unbind C-b
bind C-e send-prefix
# Mouse config
set -g mouse on
#split keeps current path
bind '|' split-window -h -c '#{pane_current_path}' # Split panes horizontal
bind '-' split-window -v -c '#{pane_current_path}' # Split panes vertically
bind c new-window -c '#{pane_current_path}' # Create new window
# 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"
unbind ^W
bind ^W split-window -p 25 -c '#{pane_current_path}' '/usr/bin/env vim .' \; swap-pane -D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment