Source

dotfiles / .tmux.conf

Full commit
# ~/.tmux.conf - tmux terminal multiplexer config
# Ches Martin    (http://chesmart.in/)

###########################################################################
#                             Global Settings                             #
###########################################################################

# tmux is supposed to figure out 256-color support from terminfo and set this,
# but it seems to fail anyway. Kind of sucks for when I run Terminal.app...
# TODO: we can use shell here to be smart-ish
set -g default-terminal "screen-256color"

# set prefix key to match screen's
set -g prefix C-a
unbind-key C-b

# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix

# disable wait after escape, so vim is usable
set-option -sg escape-time 0

# in copy mode, use vi bindings and make the mouse work
setw -g mode-keys vi
setw -g mode-mouse on

# Ctrl-p/n for tmux command history -- the vi mode is more like shell vi mode
# than vi command mode
set-option -g status-keys emacs

# scrollback buffer n lines
set -g history-limit 5000

# bells and monitoring
set -g visual-activity on
set -g visual-content on
set -g visual-silence on
set -g visual-bell on
set -g bell-action any

# purdy status bar
set -g status-bg colour236
set -g status-fg white
set -g status-left "#[fg=green][#[fg=cyan]#S#[fg=green]]#[fg=colour250] %a %Y-%m-%d %H:%M#[default]"
set -g status-left-length 35
set -g status-justify centre
setw -g window-status-current-bg colour98
set -g status-right "#H #[fg=cyan][#(uptime|cut -d ' ' -f 12-)]#[default]"

# try to set wm window titles with xterm codes
set -g set-titles on

# wm window title string (uses statusbar variables)
# set -g set-titles-string "#I:#W"

# the panes display and status messages don't show very long by default
set -g display-panes-time 2000
set -g display-time 2000

###########################################################################
#                    Key Bindings - Screen and Vim-ish                    #
###########################################################################

# I'm leaving some unbinds for defaults commented out, as I attempt to
# train myself on some tmux defaults that I like better than screen's

# reload settings
bind-key R source-file ~/.tmux.conf

# toggle previous window like screen, although prefix-l will
# be easy to get used to
bind-key C-a last-window

# vim-ish movement between and resizing of panes
bind-key -r C-h select-pane -L
bind-key -r C-j select-pane -D
bind-key -r C-k select-pane -U
bind-key -r C-l select-pane -R
bind-key -r < resize-pane -L 3
bind-key -r > resize-pane -R 3
bind-key -r J swap-pane -D
bind-key -r K swap-pane -U

# remap kill window, add confirm map before killing server
unbind &
bind-key K confirm kill-window
bind-key X confirm kill-server

bind-key m setw monitor-activity
bind-key M command-prompt -p "interval (s)" "setw monitor-silence %%"

# name window
# unbind ,
bind-key A command-prompt -I "#W" "rename-window %%"

# Keys to switch session.
bind-key Q switchc -t0
bind-key W switchc -t1
bind-key E switchc -t2

# make copy mode screen-style, with useful mouse
# unbind [
bind Escape copy-mode

# I'll give these mnemonic split bindings a try
# unbind %
# unbind '"'
bind | split-window -h
bind - split-window -v

# whizbang custom keybindings
bind-key / command-prompt -p "Man:" "split-window -h 'exec man %%'"
bind-key S command-prompt -p "SSH:" "new-window -n %1 'ssh %1'"

# present a menu of URLs to open from the visible pane. sweet.
bind-key U capture-pane \; save-buffer /tmp/tmux-buffer \; split-window -l 10 "urlview /tmp/tmux-buffer"

# Session initialization

# need a default session despite the conditionals below
new-session -d -s throwaway

# this is the best way I can find to manage host-conditional sessions
# with tmux's current config capabilities
if '[ `hostname -s` = lupin ] && ! tmux has-session -t main' 'source-file $HOME/.tmux/lupin.conf'
if '[ `hostname -s` = kodama ] && ! tmux has-session -t main' 'source-file $HOME/.tmux/kodama.conf'

# switch-client -t main
# select-window -t main:0