Skip to content

Instantly share code, notes, and snippets.

@shkm shkm/
Last active Aug 27, 2015

What would you like to do?
Sets up some tmux basics.



M-\ -- Horizontal split
M-| -- Vertical split
M-= -- Even out splits horizontally
M-+ -- Even out splits vertically
C-h -- Move to left split
C-j -- Move to lower split
C-k -- Move to upper split
C-l -- Move to right split
C-\ -- Move to previous split
M-up -- Resize split upwards
M-left -- Resize split leftwards
M-down -- Resize split downwards
M-right -- Resize split rightwards


M-j -- Next window
M-p -- Previous window


M-s -- Send task to background (fg)
C-space -- Copy mode
C-u -- Delete line
<prefix> c -- New window, like default, but with the pane's current path set

# vim:fdm=marker
# --- Basics {{{
# UTF8
set -g utf8
set-window-option -g utf8 on
# Non-stupid scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g mode-mouse on
# Default shell
set-option -g default-shell "/bin/zsh"
# Default terminal
set -g default-terminal "screen-256color"
# Faster command sequences
set -sg escape-time 0
# More obvious panes
set-option -g pane-active-border-fg colour10
# Vim keys
setw -g mode-keys vi
# Status line
set -g status on
setw -g monitor-activity on
set -g visual-activity on
set-window-option -g status-left " #S "
set-window-option -g status-left-fg black
set-window-option -g status-left-bg white
set-window-option -g status-right " %H:%M %d-%b-%y "
set-window-option -g status-right-fg black
set-window-option -g status-right-bg white
set-window-option -g window-status-format " #I: #W "
set-window-option -g window-status-current-format " #I: #W "
set-window-option -g window-status-current-fg green
set-window-option -g window-status-current-bg black
# --- Basics }}}
# --- Mappings {{{
# Copy mode
bind -n C-Space copy-mode
bind ESCAPE copy-mode
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
bind -t vi-copy V rectangle-toggle
bind ] paste-buffer
# Pane/Window management
bind -n M-\ split-window -h -c '#{pane_current_path}'
bind -n M-- split-window -v -c '#{pane_current_path}'
bind -n M-= select-layout even-horizontal
bind -n M-+ select-layout even-vertical
bind -n M-j next-window
bind -n M-k previous-window
bind -n M-s send-keys C-z \; send-keys " reset && fg > /dev/null" \; send-keys "Enter"
# Pane navigation
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
# Pane resizing
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
bind-key -nr M-z resize-pane -Z
# Session management
bind-key -n M-8 choose-session
bind-key -n M-9 switch-client -p
bind-key -n M-0 switch-client -n
# General
bind-key -t vi-edit C-u delete-line
# Set new window dir to current pane's
bind c new-window -c "#{pane_current_path}"
# --- Mappings }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.