Source

dotfiles / dot.tmux.conf

Full commit
# ~/.tmux.conf

set -g prefix C-z
unbind-key C-b
bind-key C-z send-prefix
bind-key z send-prefix

# common prefix between normal or nesting session
if '[ "$(tmux -V | sed "s/[^0-9]//g")" -ge 16 ]' \
   'set -g prefix2 C-M-z; bind-key C-M-z send-prefix -2'

bind-key h command-prompt -p '(ssh)' \
           "if 'tmux has -t ssh' \
               'switchc -t ssh; neww -n %1 \"ssh -t %1 tmux -2u attach\"' \
               'new -s ssh -n %1 \"tmux source ~/.tmux.nesting.conf; \
                                   ssh -t %1 tmux -2u attach\"'"
bind-key / last-window

# allow common typo
unbind-key C-o
bind-key C-c new-window
bind-key C-n next-window
bind-key C-p previous-window

set -g default-terminal "screen-256color"
if '[ "$(tmux -V | sed "s/[^0-9]//g")" -ge 12 ]' 'set -g escape-time 0'

if '[ -n "$SSH_CONNECTION" ]' \
   'set -g status-bg colour30' \
   'set -g status-bg colour34'

# renumber window from 1
set -g base-index 1
if '[ "$(tmux -V | sed "s/[^0-9]//g")" -ge 17 ]' 'set -g renumber-windows on'

# switch to existing session when session destroyed
set -g detach-on-destroy off

# X11 clipboard
bind-key M-w run "tmux save-buffer - | xclip -i -selection clipboard"
bind-key C-y run "xclip -o -selection clipboard | tmux load-buffer - && tmux paste-buffer"

# prepare default session so that 'tmux attach' always succeeds
# http://stackoverflow.com/a/4717750
new-session