Skip to content

Instantly share code, notes, and snippets.

@jballanc
Created August 22, 2013 11:21
Show Gist options
  • Save jballanc/6306001 to your computer and use it in GitHub Desktop.
Save jballanc/6306001 to your computer and use it in GitHub Desktop.
new-session
set -g default-command "reattach-to-user-namespace -l zsh"
set -g status-bg black
set -g status-fg green
setw -g window-status-current-bg yellow
setw -g window-status-current-fg black
set -g base-index 1
set -g renumber-windows on
set -g mode-keys vi
set -g utf8 on
set -g prefix C-w
unbind C-b
# Smart pane switching with awareness of vim splits
bind h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w h) || tmux select-pane -L"
bind j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w j) || tmux select-pane -D"
bind k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w k) || tmux select-pane -U"
bind l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w l) || tmux select-pane -R"
bind w run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w w) || tmux last-pane"
bind C-w run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w C-w) || tmux last-pane"
# Smart window splitting with awareness of vim
bind s run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w s) || tmux split-window -v"
bind C-s run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w C-s) || tmux split-window -v"
bind v run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w v) || tmux split-window -h"
bind C-v run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w C-v) || tmux split-window -h"
# Pass through vim split reorg commands
bind H send-keys C-w H
bind J send-keys C-w J
bind K send-keys C-w K
bind L send-keys C-w L
bind = send-keys C-w =
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment