not logged in | [Login]


Here's my tmux config, it has the following:

  • To switch between windows, press alt followed by either a < or >.
  • Tabs in the bottom left showing windows. The activate tab is highlighted.
  • The current time is printed at the lower right in both local and UTC

Location: ~/.tmux.conf

# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# Make new windows open in the current path
bind c new-window -c "#{pane_current_path}"

# Sane scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'

# enable vi style bindings
set-window-option -g mode-keys vi

# Set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1

# make tmux display things in 256 colors
set -g default-terminal "screen-256color"

# set scrollback history to 10000 (10k)
set -g history-limit 10000

# use UTF8
set -g utf8
set-window-option -g utf8 on

# Make the ALT < and ALT > keys move to the prev/next windows
bind-key -n M-"," previous-window
bind-key -n M-"." next-window

set-option -g status-utf8 on
set -g set-titles on
setw -g window-status-current-bg '#55ff55'
setw -g window-status-current-fg '#000000'
set -g status-bg '#4e4e4e'
set -g status-fg '#ffffff'
set -g window-status-format '#I #W'
set -g window-status-current-format ' #I #W '
set -g status-left-length 20
set -g status-right-length 30
set -g status-left ' '
set -g status-right "#[fg=yellow]#(TZ=America/Los_Angeles date '+%%Y-%%b-%%d %%H:%%M') #[fg=green] | #(TZ=UTC date -u +%%H:%%M) UTC"
set -g status-interval 5 # Default 15 seconds
#set -g status-justify centre

# reload ~/.tmux.conf using PREFIX r
#bind r source-file ~/.tmux.conf \; display "Reloaded!"
bind r source-file ~/.tmux.conf

Management script

tm() {
    if [ -z $1 ]; then
        tmux list-sessions
    tmux detach -s $1 2> /dev/null
    tmux attach-session -t $1 2> /dev/null || tmux new-session -s $1

_tm() {
  local word completions
  sessions=`tmux list-sessions 2> /dev/null`
  [ $? -ne 0 ] && return
  completions=`echo "$sessions" | cut -d ':' -f1`
  reply=( "${(f)completions}" )
compctl -K _tm tm