Skip to content

Instantly share code, notes, and snippets.

@PeterGrace
Created March 27, 2015 13:16
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 PeterGrace/15a89d3e650a2224580d to your computer and use it in GitHub Desktop.
Save PeterGrace/15a89d3e650a2224580d to your computer and use it in GitHub Desktop.
pete's tmux config
# Clear the two common binds for prefix to "clean the slate"
unbind C-a
unbind C-b
#I need this in cygwin to make mouse mode work properly, might not be needed for others
set -sg escape-time 250
#make the command prefix control+a
set -g prefix C-a
# 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 xterm-256color
# Watch for activity in background windows
setw -g monitor-activity on
# this permits one to keep their finger on ctrl while detaching or creating a new window
bind-key ^D detach-client
bind-key ^C new-window
#Unbind a bunch of stuff
unbind -
unbind _
unbind '\'
unbind '|'
unbind s
unbind C-s
unbind v
unbind C-v
#split horizontally
bind-key - split-window
bind-key _ split-window
bind-key s split-window
bind-key C-s split-window
#split vertically
bind-key \ split-window -h
bind-key | split-window -h
bind-key v split-window -h
bind-key C-v split-window -h
#prefix + ctrl-y causes the last 32768 lines of the tmux scroll buffer to go into cygwin's clipboard sharing.
#Might not work on other platforms
bind-key C-y\
capture-pane -S -32768 \;\
save-buffer /dev/clipboard \;\
delete-buffer\;
# Pane resize in all four directions using vi bindings.
# Can use these raw but I map them to Cmd-Opt-<h,j,k,l> in iTerm2.
# http://tangledhelix.com/blog/2012/04/28/iterm2-keymaps-for-tmux/
bind-key J resize-pane -D
bind-key K resize-pane -U
bind-key H resize-pane -L
bind-key L resize-pane -R
#Use prefix+j to go to the previous window we were looking at
bind-key j previous-window
#Honestly, I can't remember why this is here.
bind-key s-enter send-key enter
# 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 scrollback limit to 10000. Funny, I capture 32768 in the buffer grab but I only ever have 10k....
set -g history-limit 10000
#resize... aggressively?
setw -g aggressive-resize on
#Not sure, I don't think I've used this, but my guess is it causes tmux to redraw
bind R refresh-client
#Sometimes if I'm ssh'd into another box with tmux, I need a way to send ctrl-a to that box. So, prefix + a sends ctrl-a which
#I can then use to do tmux commands in the nested connection
bind a send-key C-a
# 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
#This command is similar to the scrollback buffer command, but will save the scrollback to a file instead.
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer'
# 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
# + and - "zoom" and "unzoom" a pane.
# + breaks a pane out to its own window
# - restores a broken-out pane to being a pane
# This is native as of 1.8 (prefix z)
#unbind +
#bind + \
# new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
# swap-pane -s tmux-zoom.0 \;\
# select-window -t tmux-zoom
#
#unbind -
#bind - \
# last-window \;\
# swap-pane -s tmux-zoom.0 \;\
# kill-window -t tmux-zoom
# reload tmux config
unbind r
bind r \
source-file ~/.tmux.conf \;\
display 'Reloaded tmux config.'
set -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 \
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'
# 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=colour252,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=colour39]⮀#[fg=colour25,bg=colour39,noreverse,bold] #I ⮁ #W #[fg=colour39,bg=colour234,nobold]⮀"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment