[Ubuntu] My .tmux.conf

(Last Update: ) 3 minute read

.tmux.conf

# Inspirations:
# http://mutelight.org/practical-tmux
# http://zanshin.net/2013/09/05/my-tmux-configuration/
# http://files.floriancrouzat.net/dotfiles/.tmux.conf
# http://stackoverflow.com/questions/9628435/tmux-status-bar-configuration
# https://github.com/Lokaltog/powerline
# https://github.com/remiprev/teamocil
# http://superuser.com/questions/74492/whats-the-best-prefix-escape-sequence-for-screen-or-tmux
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
#

set-option -g status-utf8 on
setw -g utf8 on
set -g default-terminal "screen-256color"
set-option -g default-shell /bin/zsh

# ***WARNING!*** tmux will exit immediately if this plugin is not installed!!!
# http://superuser.com/questions/397076/tmux-exits-with-exited-on-mac-os-x
# set-option -g default-command "reattach-to-user-namespace -l $SHELL"

# change default prefix (C-b) to C-space
unbind C-a
set -g prefix C-a
bind C-a send-prefix

# allow xterm keys
set-window-option -g xterm-keys on

# start numbering from 0 instead of 1
set -g base-index 0
setw -g pane-base-index 0

# bind C-a C-a to last active window
bind-key C-a last-window

# get rid of delay reading command characters while tmux waits for escape sequence
set -s escape-time 1

# reload ~/.tmux.conf using prefix r
bind r source-file ~/.tmux.conf \; display "tmux reloaded"

# change split prefixes (horizontal: C-space /) (vertical: C-space -)
bind / split-window -h
bind - split-window -v

# make current window the 1st window
bind T swap-window -t 1

# set scrollback history to 10K lines
set -g history-limit 1000000

# mouse support
if-shell "tmux -V |awk ' {split($2, ver, \".\"); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }' " 'source ~/.tmux/gt_2.0.conf' 'source ~/.tmux/lt_2.1.conf'

# 1.8
#setw -g mode-mouse on; set -g mouse-select-window on; set -g mouse-select-pane on; set -g mouse-resize-pane on; set -g mouse-utf on

# 2.1
#set -g mouse on
#bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"

# vi
# ==
setw -g mode-keys vi
set -g status-keys vi

# setup 'v' to begin selection as in vim
#bind-key -t vi-copy v begin-selection
#bind-key -t vi-copy r rectangle-toggle
#bind-key -t vi-copy y copy-pipe "xclip -sel clip -i"
#bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'r' rectangle-toggle
bind -t vi-copy 'y' copy-selection
bind -t vi-copy 'y' copy-pipe "xclip -sel clip -i"

# update default binding of `Enter` to also use copy-pipe (os x)
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

# map vi movement keys as pane movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# use vi left and right to cycle thru panes
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# resize panes using vi keys
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# window mode
# ===========
setw -g mode-bg colour6
setw -g mode-fg colour0

# window status
# =============
set-option -g automatic-rename off
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W "
setw -g window-status-current-bg colour0
setw -g window-status-current-fg colour11
setw -g window-status-current-attr dim
setw -g window-status-bg green
setw -g window-status-fg black
setw -g window-status-attr reverse

# panes
# =====
set -g pane-border-bg colour0
set -g pane-border-fg colour255
set -g pane-active-border-bg colour0
set -g pane-active-border-fg colour214

# status bar
# ==========
set -g status-justify left
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-attr dim
set -g status-left '#[fg=colour233,bg=colour245,bold] [#S] '
set -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20

setw -g window-status-current-fg colour81
setw -g window-status-current-bg colour238
setw -g window-status-current-attr bold
setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '

setw -g window-status-fg colour138
setw -g window-status-bg colour235
setw -g window-status-attr none
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '

setw -g window-status-bell-attr bold
setw -g window-status-bell-fg colour255
setw -g window-status-bell-bg colour1

#set -g status-right-length 60
# set -g status-right "#S #I:#P %d %b %Y %l:%M %p (#(date -u | awk '{print $4}' | cut -c1-5))"

set-option -g set-titles on

# quiet!
# http://unix.stackexchange.com/questions/169992/why-are-my-windows-highlighted-when-i-first-open-tmux
setw -g monitor-activity off
set -g monitor-silence 0
set -g bell-action none

set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
set -g bell-action none

./tmux/gt_2.0.conf

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"

./tmux/lt_2.0.conf

setw -g mode-mouse on
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-utf on

Leave a Comment