Skip to content

Instantly share code, notes, and snippets.

@rafi
Created May 17, 2016 11:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafi/f732cb99530eeaabe9546641f570e2d6 to your computer and use it in GitHub Desktop.
Save rafi/f732cb99530eeaabe9546641f570e2d6 to your computer and use it in GitHub Desktop.
Sensible tmux config
set-option -g set-titles on
set-option -g set-titles-string '#T #W tmux{#S}:#I.#P'
set-window-option -g automatic-rename on
set-option -g history-limit 6000
set-option -s escape-time 0
set-option -g display-time 4000
set-option -g repeat-time 300
set-window-option -g aggressive-resize on
set-option -g base-index 1
set-window-option -g pane-base-index 1
set-option -g visual-bell off
set-option -g visual-activity off
set-option -g visual-silence off
# Act like GNU screen, use C-a instead of C-b
unbind-key C-b
set-option -g prefix C-a
# In nested tmux clients, send prefix with C-a a
bind-key a send-prefix
bind-key c new-window -c "#{pane_current_path}"
bind-key N new-session
# Use v and g for splitting from current path
unbind-key %
unbind-key '"'
bind-key g split-window -h -c "#{pane_current_path}"
bind-key v split-window -v -c "#{pane_current_path}"
# Session movement
bind-key n switch-client -n
bind-key p switch-client -p
# Window movement
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
bind-key -n M-9 previous-window
bind-key -n M-0 next-window
# Pane movement
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Toggle synchronized input to all panes in current window
bind-key S set-window-option synchronize-panes
# Use a tick for renaming the window prompt
unbind-key ','
bind-key ` command-prompt -I '#W' -p 'Rename window>' "rename-window '%%'"
unbind-key '$'
bind-key '$' command-prompt -I '#S' -p 'Rename session>' "rename-session '%%'"
# Open a man page in new vertical pane
bind-key / command-prompt -p 'Man>' "split-window -d -v 'exec man %%'"
# Quick view of processes
bind-key P split-window -h 'exec htop'
# Help screen: rebind list-keys window into a new pane
bind-key ? split-window -h 'exec tmux list-keys | less'
# Search for previous error
bind-key e copy-mode \; send-keys "?error" C-m
bind-key Escape copy-mode
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy V select-line
bind-key -t vi-copy C-v rectangle-toggle
bind-key -t vi-copy Escape clear-selection
# Mouse (tmux >= 2.1)
#-------------------------------------------------
# Allows scrolling and selecting in copy-mode
set-option -g -q mouse on
# Enable mouse copy-mode scrolling
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
# Enable fast scrolling with Ctrl
bind-key -T root C-WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -t vi-copy C-WheelUpPane halfpage-up
bind-key -t vi-copy C-WheelDownPane halfpage-down
# Make mouse-drag work only with Ctrl
unbind -T root MouseDrag1Pane
unbind -t vi-copy MouseDrag1Pane
bind-key -n C-MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -M\" \"send-keys -M\"' 'copy-mode -M'
bind-key -t vi-copy C-MouseDrag1Pane begin-selection
# Toggle mouse on/off
bind-key m set-option -g mouse on \; display 'Mouse: ON'
bind-key M set-option -g mouse off \; display 'Mouse: OFF'
# Look n Feel
#-------------------------------------------------
#
# *-attr options accept: none, bright (or bold), dim, underscore, blink,
# reverse, hidden, or italics.
set-option -g message-fg colour11
set-option -g message-bg colour236
set-option -g message-attr none
set-option -g message-command-fg colour253
set-option -g message-command-bg colour236
set-option -g message-command-attr none
set-option -g pane-border-fg colour240
set-option -g pane-border-bg default
set-option -g pane-active-border-fg colour4
set-option -g pane-active-border-bg colour235
set-option -g display-panes-active-colour colour220
set-option -g display-panes-colour colour74
set-window-option -g mode-fg colour11
set-window-option -g mode-bg colour236
set-window-option -g mode-attr none
set-window-option -g clock-mode-colour colour64
set-window-option -g clock-mode-style 24
# Status lines
#-------------------------------------------------
set-option -g status on
set-option -g status-position top
set -g status-justify left
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment