################################################################################
# Options.
################################################################################
# Use vi keys for scrolling etc.
# Use lsk -t vi|emacs-
to see binds in table choice, copy or edit.
setw -g mode-keys vi
set -g status-keys vi
# Don't wait so long to parse escape sequences.
set -s escape-time 100
# Clock.
setw -g clock-mode-colour white
setw -g clock-mode-style 24
# Scrollback buffer.
set -g history-limit 4096
# Don't use the mouse to select text by default.
# It has two important flaws. Double-clicking to select a word doesn't work.
# Middle clicking to paste doesn't work.
set -g mouse-resize-pane off
set -g mouse-select-pane off
set -g mouse-select-window off
set -g mode-mouse off
################################################################################
# Screen compatibility.
################################################################################
set -g prefix C-p
unbind C-b
bind C-p last-window
bind p send-keys C-p
bind S split-window -v
bind | split-window -h
bind C-[ copy-mode
bind ] paste-buffer
bind C-] paste-buffer
bind _ setw monitor-activity
bind M-_ setw monitor-silence 10
bind * list-clients
bind < command-prompt -p "Load buffer from file:" 'load-buffer %1'
bind > command-prompt -p "Save buffer to file:" 'save-buffer %1'
################################################################################
# Hotkeys.
################################################################################
# Up and down like Vim.
bind j select-pane -D
bind -r C-j select-pane -D
bind k select-pane -U
bind -r C-k select-pane -U
# Don't let arrow keys repeat.
bind Up select-pane -U
bind Down select-pane -D
bind Left select-pane -L
bind Right select-pane -R
# Previous and next panes kinda like Vim.
bind h select-pane -L
bind -r C-h select-pane -L
bind l select-pane -R
bind -r C-l select-pane -R
# And for windows.
bind -r H previous-window
bind -r L next-window
# Last window like Vim.
bind ^ last-window
bind C-^ last-pane
bind C-o last-pane
# Top and bottom.
bind J select-pane -D
bind K select-pane -U
# Swap panes.
bind o swap-pane -D
bind -r O swap-pane -U
bind w command-prompt -p "Select [.] to swap:" 'swap-pane -s . -t %1'
# Swap windows.
bind W choose-window "swap-window -t '%%'"
# Show panes.
bind = display-panes
# Move the current pane into a separate window.
bind b break-pane
# Split another pane into this window.
bind B command-prompt -p "Select [.] to join:" 'join-pane -s %1'
# Split vertically.
bind C-\ split-window -v
# Next pane.
bind i select-pane -t :.+
bind -r C-i select-pane -t :.+
bind -r I select-pane -t :.-
# Resize pane.
bind -r C-M-h resize-pane -L
bind -r C-M-j resize-pane -D
bind -r C-M-k resize-pane -U
bind -r C-M-l resize-pane -R
# Layouts.
bind , select-layout even-vertical
bind . select-layout even-horizontal
bind / select-layout tiled
bind M-, select-layout main-vertical
bind M-. select-layout main-horizontal
bind Space next-layout
bind -r C-Space next-layout
# Simulate maximising the window.
bind / select-layout main-horizontal \; resize-pane -D 9999
bind M-/ select-layout tiled
# Select windows.
bind - choose-window
bind M-0 select-window -t 10
bind M-1 select-window -t 11
bind M-2 select-window -t 12
bind M-3 select-window -t 13
bind M-4 select-window -t 14
bind M-5 select-window -t 15
bind M-6 select-window -t 16
bind M-7 select-window -t 17
bind M-8 select-window -t 18
bind M-9 select-window -t 19
# Set current window title.
bind t command-prompt -p "Set window's title to:" 'rename-window %1'
# Show clock.
bind T clock-mode
# Monitor window for a particular string.
bind m command-prompt -p "Monitor:" 'setw monitor-content %1'
bind M setw monitor-content ""
# Synchronise input.
bind \; setw synchronize-panes
# Choose buffer to paste.
bind } choose-buffer 'paste-buffer -b %%'
# Enter copy-mode and scroll up.
bind { copy-mode -u
# Choose buffer to show.
# XXX: As of tmux 1.3 this doesn't work.
#bind '"' choose-buffer 'show-buffer -b %%'
bind '"' list-buffers \; command-prompt -p "Choose buffer to show:" 'show-buffer -b %1'
bind "'" new-window -n "[buffer]" "cat > /dev/null" \; paste-buffer
# Toggle mouse mode as it is useful despite the flaws listed above.
bind C-m set -g mouse-resize-pane \; set -g mouse-select-pane \; set -g mouse-select-window \; set -g mode-mouse
################################################################################
# Fix missing binds in Vi modes.
################################################################################
# Command prompt.
bind -t vi-edit C-u delete-line
# We can't delete a word so ^w can clear the whole line for now.
bind -t vi-edit C-w delete-line
bind -t vi-edit Up history-up
bind -t vi-edit Down history-down
bind -t vi-edit Left cursor-left
bind -t vi-edit Right cursor-right
# Copy mode.
bind -t vi-copy y copy-selection
################################################################################
# Terminal settings.
################################################################################
set -g default-terminal 'screen-256color'
# PuTTY needs help to set bold colours.
set -a -g terminal-overrides ',putty-256color:C8:Ms=\\E]52;%p1%s;%p2%s\\007m'
################################################################################
# Window and pane settings.
################################################################################
set -g display-panes-time 1000
set -g display-panes-active-colour white
set -g display-panes-colour colour17
# Command entry.
set -g message-bg colour90
set -g message-fg white
set -g message-command-bg colour88
set -g message-command-fg white
# Active pane
set -g pane-active-border-bg default
set -g pane-active-border-fg white
# Inactive pane.
set -g pane-border-bg default
set -g pane-border-fg colour17
# Messages.
setw -g mode-bg blue
setw -g mode-fg white
# Monitored windows (in reverse video).
setw -g window-status-alert-bg red
setw -g window-status-alert-fg white
# As of tmux 1.6 we can highlight different alerts.
setw -g window-status-bell-bg colour22
setw -g window-status-bell-fg white
setw -g window-status-content-bg colour88
setw -g window-status-content-fg white
setw -g window-status-content-attr none
setw -g window-status-activity-bg red
setw -g window-status-activity-fg white
################################################################################
# Caption settings.
################################################################################
# Don't update the title bar.
set -g set-titles off
# Status line black on white.
set -g status-attr none
set -g status-bg white
set -g status-fg black
# Current window white on blue.
setw -g window-status-current-attr none
setw -g window-status-current-bg colour17
setw -g window-status-current-fg white
# No border.
set -g status-left ''
set -g status-right '#[fg=white,bg=colour8][#H:#S]'
# Window flags.
setw -g window-status-current-format '[#I.#P#F #W]'
setw -g window-status-format ' #I.#P#F #W '
# Don't set window name. XXX: Issue with PROMPT_COMMAND.
#setw -g automatic-rename off