Skip to content

Instantly share code, notes, and snippets.

@trevorrjohn
Created August 6, 2018 21:32
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 trevorrjohn/93685b0621c885304b0456497e5d58ae to your computer and use it in GitHub Desktop.
Save trevorrjohn/93685b0621c885304b0456497e5d58ae to your computer and use it in GitHub Desktop.
tmux.conf
# brew install reattach-to-user-namespace
# https://robots.thoughtbot.com/how-to-copy-and-paste-with-tmux-on-mac-os-x
set-option -g default-command "reattach-to-user-namespace -l bash"
# Act like Vim
set-window-option -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Look good
set-option -g default-terminal "screen-256color"
# Enable mouse support (works in iTerm)
set-option -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# set-window-option -g mode-mouse on
# set-option -g mouse-select-pane on
# set-option -g mouse-resize-pane on
# set-option -g mouse-select-window on
#===========
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode 'Enter' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
#===========
# Set up copy like vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# set up layouts
# set main-pane-width 130
# Change cursor in vim to distinguish between insert and command mode
set-option -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,xterm*:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]112\007:Cs=\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%p1%{2}%-%;%d\007'
# scrollback buffer size increase
set -g history-limit 500000
# C-b C-b will swap to last used window
bind-key C-b last-window
# Start tab numbering at 1
set-option -g base-index 1
set-window-option -g pane-base-index 1
# Allows for faster key repetition
set -s escape-time 0
# Highlight active window
set-window-option -g window-status-current-bg red
# use different keys to split vertical and horizonal
bind | split-window -h
bind - split-window -v
# Change cursor in vim to distinguish between insert and command mode
# Use in conjunciton with tmux-cursors.vim
set-option -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,xterm*:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]112\007:Cs=\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%p1%{2}%-%;%d\007'
# use C-b v to paste the tmux buffer
bind v paste-buffer
# Use vim keybindings in copy mode
setw -g mode-keys vi
set -g @tpm_plugins "\
tmux-plugins/tpm \
tmux-plugins/tmux-yank \
tmux-plugins/tmux-copycat \
tmux-plugins/tmux-open \
"
run-shell '~/.tmux/plugins/tpm/tpm'
# switch between zoomed panes
bind-key a select-pane -t .+1 \; resize-pane -Z
# turn on focus events
set -g focus-events on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment