Skip to content

Instantly share code, notes, and snippets.

@anowell
Last active December 19, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anowell/5988925 to your computer and use it in GitHub Desktop.
Save anowell/5988925 to your computer and use it in GitHub Desktop.
tmux config
# Bind prefix to tick, but let double-tick through
unbind `
set -g prefix `
bind-key ` send-key `
# Ring the bell if any background window rang a bell
set -g bell-action any
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# Watch for activity in background windows
# setw -g monitor-activity on
# Window and pane switching
unbind l
bind-key l last-pane
bind-key L last-window
bind-key j select-pane -t :.-
bind-key k select-pane -t :.+
bind-key b previous-window
#bind-key n next-window
# Force split-window to use current path
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -c "#{pane_current_path}" -h
# Pane resize in all four directions using vi bindings.
# http://tangledhelix.com/blog/2012/04/28/iterm2-keymaps-for-tmux/
bind-key -r J resize-pane -D
bind-key -r K resize-pane -U
bind-key -r H resize-pane -L
bind-key -r L resize-pane -R
# Use vi keybindings for tmux commandline input.
# Note that to get command mode you need to hit ESC twice...
set -g status-keys vi
# Use vi keybindings in copy and choice modes
setw -g mode-keys vi
set -g history-limit 10000
setw -g aggressive-resize on
# bind R refresh-client
# Vim-style copy/paste
unbind [
bind y copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy H start-of-line
bind -t vi-copy L end-of-line
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
bind -t vi-copy Escape cancel
# Ctrl-s to save the current pane's history to a file
bind-key C-s command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer'
# Seamless pane switching between tmux and vim
# http://robots.thoughtbot.com/seamlessly-navigate-vim-and-tmux-splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
# easily toggle synchronization (mnemonic: e is for echo)
# sends input to all panes in a given window.
bind e setw synchronize-panes on
bind E setw synchronize-panes off
# set first window to index 1 (not 0) to map more to the keyboard layout...
set -g base-index 1
setw -g pane-base-index 1
# reload tmux config
unbind r
bind r \
source-file ~/.tmux.conf \;\
display 'Reloaded tmux config.'
# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
setw -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
# Toggle mouse on
bind m \
setw -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 \
setw -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'
# pass through xterm keys
set -g xterm-keys on
# color scheme (style based on vim-powerline)
set -g status-left-length 52
set -g status-right-length 451
set -g status-fg white
set -g status-bg colour234
set -g window-status-activity-attr bold
set -g pane-border-fg colour245
set -g pane-active-border-fg colour46
set -g message-fg colour16
set -g message-bg colour221
set -g message-attr bold
set -g status-left '#[fg=colour235,bg=colour252,bold] ❐ #S #[fg=colour253,bg=colour238,nobold]#[fg=colour245,bg=colour238,bold] #(whoami) |#[fg=colour238,bg=colour234,nobold]'
set -g window-status-format "#[fg=white,bg=colour234] #I.#W |"
set -g window-status-current-format "#[fg=colour234,bg=colour33,noreverse,bold] #I.#W #[fg=white,bg=colour234] |"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment