Skip to content

Instantly share code, notes, and snippets.

@mickours
Created June 4, 2015 08:59
Show Gist options
  • Save mickours/fc05b1762fca1f930ef6 to your computer and use it in GitHub Desktop.
Save mickours/fc05b1762fca1f930ef6 to your computer and use it in GitHub Desktop.
My tmux configuration file
# Allows for faster key repetition
set -s escape-time 0
# Keep quiet and don't display warnings.
set-option -g quiet on
# Interact with xterm clipboard.
set-option -g set-clipboard on
# Window numbering starts from '1', '0' is too far away.
set-option -g base-index 1
# Ring the terminal bell from any window, in URxvt this is disabled, but activity is recorded.
set-option -g bell-action any
set-option -g bell-on-alert on
# Pretend to be 'screen', easier as many scripts already recognise the $TERM string.
set-option -g default-terminal "screen-256color"
# The maximum number of lines held in history, mirror URxvt configuration.
set-option -g history-limit 102400
# Redraw the status line more frequently than the default.
set-option -g status-interval 2
# Use Vi key bindings on the tmux command line.
set-option -g status-keys vi
# Treat top-bit-set characters in the 'status-left' and 'status-right' strings as UTF-8.
set-option -g status-utf8 on
# Scrolling with Shift-PageUp/Shift-PageDown.
set -g terminal-overrides "*rxvt*:smcup@:rmcup@"
# Disable annoying visual bells.
#set-option -g visual-bell off
set-window-option -g utf8 on
set -g history-limit 100000
set-option -g set-titles on
set-window-option -g alternate-screen on
# Use Vi key bindings for copy/paste operations.
set-window-option -g mode-keys vi
# Watch for activity in windows and highlight on the status line.
set-window-option -g monitor-activity on
# Numbering for panes is same as numbering for windows.
set-window-option -g pane-base-index 1
# Enable xterm-style key sequences and modifiers such as Ctrl, Alt and Shift.
set-window-option -g xterm-keys on
# Allow each window to take up the maximum monitor width/height without forcing others.
set-window-option -g aggressive-resize on
# Key bindings.
# C-b is not acceptable
set-option -g prefix C-a
# enter copy mode & scroll 1 page up with alt+pageup
bind-key -n S-PPage copy-mode -u
unbind A
bind A command-prompt "rename-window %%"
# Cycle panes.
bind b select-pane -t :.+
bind C-b select-pane -t :.+
# Don't prompt to kill panes/windows.
unbind x
bind-key x kill-pane
unbind k
bind k kill-window
# Allows us to use C-a a <command> to send commands to a TMUX session inside
# another TMUX session
bind-key a send-prefix
bind-key C-a send-prefix
# Re-read the configuration file in a running session.
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
# # Clipboard manipulation.
# bind-key C-c run "tmux save-buffer - | xclip -i -selection clipboard"
# bind-key C-v run "tmux set-buffer -- \"$( xclip -o -selection clipboard )\"; tmux paste-buffer"
# set vi keys
unbind [
bind Escape copy-mode
setw -g mode-keys vi
unbind p
bind p paste-buffer
# Setup 'v' to begin selection as in Vim
#bind-key -t vi-copy 'v' begin-selection
#bind-key -t vi-copy 'y' copy-pipe "xclip -i -selection clipboard"
# Update default binding of `Enter` to also use copy-pipe
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "xclip -i -selection clipboard"
# Split like terminator
unbind %
bind C-e split-window -h
unbind '"'
bind C-o split-window -v
bind | split-window -h
bind - split-window
unbind ]
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Toggle mouse on
set -g mode-mouse off
bind m \
set -g mode-mouse on \;\
set -g mouse-resize-pane on \;\
set -g mouse-select-pane on \;\
set -g mouse-select-window on \;\
display 'Mouse: ON'
# Toggle mouse off
bind M \
set -g mode-mouse off \;\
set -g mouse-resize-pane off \;\
set -g mouse-select-pane off \;\
set -g mouse-select-window off \;\
display 'Mouse: OFF'
# Ctrl-Left/Right cycles thru windows (no prefix)
bind -n M-PageDown next-window
bind -n M-PageUp previous-window
bind -n C-PageDown next-window
bind -n C-PageUp previous-window
bind-key -n "M-6" next-window
bind-key -n "M-4" previous-window
bind n new-window
bind C-n new-window
# open a man page in new window
bind-key / command-prompt "split-window 'exec man %%'"
# quick view of processes
bind-key h split-window -h "htop --sort-key \"CPU%\""
# Formatting & Colours.
set-option -g mode-bg colour220
set-option -g mode-fg colour16
set-option -g status-bg colour232
set-option -g status-fg colour247
set-option -g pane-border-fg colour238
set-option -g pane-active-border-fg colour248
set-option -g message-bg colour232
set-option -g message-fg colour220
set-option -g message-attr bold
set-window-option -g window-status-activity-fg colour251
set-window-option -g window-status-bell-fg colour251
set-window-option -g window-status-activity-attr bold
set-window-option -g window-status-bell-attr bold
# clock
set-window-option -g clock-mode-colour colour64 #green
# Set cool status bar
set -g status-justify centre # center align window list
set -g status-left-length 20
set -g status-right-length 140
set -g status-left '#[fg=green]#H #[fg=black]•'
set -g status-right '#(~/.bin/tmux-info 1)'
# smart pane switching with awareness of vim splits
bind -n M-Left run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n M-Right run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n M-Up run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n M-Down run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim$' && tmux send-keys C-j) || tmux select-pane -D"
# syncro
#unbind s
#bind s set -g synchronize-panes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment