Skip to content

Instantly share code, notes, and snippets.

@NullVoxPopuli
Last active December 11, 2015 20:05
Show Gist options
  • Save NullVoxPopuli/6441784bf83010f2efd1 to your computer and use it in GitHub Desktop.
Save NullVoxPopuli/6441784bf83010f2efd1 to your computer and use it in GitHub Desktop.
Because learning a new set of commands is non-trivial to keep in long term memory (esp it Chrome closes and you don't remember where you found that one cheat sheet)
# First remove *all* keybindings
unbind-key -a
# Now reinsert all the regular tmux keys
# bind-key C-b send-prefix
bind-key C-o rotate-window
bind-key C-z suspend-client
bind-key Space next-layout
bind-key ! break-pane
# bind-key " split-window
# bind-key # list-buffers
# bind-key $ command-prompt -I #S "rename-session '%%'"
# bind-key % split-window -h
bind-key & confirm-before -p "kill-window #W? (y/n)" kill-window
# bind-key ' command-prompt -p index "select-window -t ':%%'"
# bind-key ( switch-client -p
# bind-key ) switch-client -n
# bind-key , command-prompt -I #W "rename-window '%%'"
bind-key - delete-buffer
# bind-key . command-prompt "move-window -t '%%'"
bind-key 0 select-window -t :0
bind-key 1 select-window -t :1
bind-key 2 select-window -t :2
bind-key 3 select-window -t :3
bind-key 4 select-window -t :4
bind-key 5 select-window -t :5
bind-key 6 select-window -t :6
bind-key 7 select-window -t :7
bind-key 8 select-window -t :8
bind-key 9 select-window -t :9
bind-key : command-prompt
# bind-key ; last-pane
bind-key = choose-buffer
bind-key ? list-keys
# bind-key D choose-client
# bind-key L switch-client -l
bind-key [ copy-mode
bind-key ] paste-buffer
bind-key c new-window
# bind-key d detach-client
bind-key f command-prompt "find-window '%%'"
bind-key i display-message
# bind-key l last-window
bind-key n next-window
bind-key o select-pane -t :.+
bind-key p previous-window
bind-key q display-panes
bind-key r refresh-client
bind-key s choose-session
bind-key t clock-mode
bind-key w choose-window
bind-key x confirm-before -p "kill-pane #P? (y/n)" kill-pane
bind-key { swap-pane -U
bind-key } swap-pane -D
# bind-key ~ show-messages
bind-key PPage copy-mode -u
bind-key -r Up select-pane -U
bind-key -r Down select-pane -D
bind-key -r Left select-pane -L
bind-key -r Right select-pane -R
bind-key -r M-1 select-layout even-horizontal
bind-key -r M-2 select-layout even-vertical
bind-key -r M-3 select-layout main-horizontal
bind-key -r M-4 select-layout main-vertical
bind-key -r M-5 select-layout tiled
bind-key -r M-n next-window -a
bind-key -r M-o rotate-window -D
bind-key -r M-p previous-window -a
bind-key -r M-Up resize-pane -U 5
bind-key -r M-Down resize-pane -D 5
bind-key -r M-Left resize-pane -L 5
bind-key -r M-Right resize-pane -R 5
bind-key -r C-Up resize-pane -U
bind-key -r C-Down resize-pane -D
bind-key -r C-Left resize-pane -L
bind-key -r C-Right resize-pane -R
############################################################################
# Bindings
############################################################################
# reload tmux conf
# bind-key r source-file ~/.tmux.conf
# prefix
set -g prefix C-a
# bind C-a send-prefix
bind-key v split-window -v # split pane horizontally
bind-key h split-window -h # split pane vertically
# Resizing ---------------------------------------------------------------
# must preceed with the prefix
bind-key C-l resize-pane -L
bind-key C-d resize-pane -D
bind-key C-u resize-pane -U
bind-key C-r resize-pane -R
# colors
setw -g mode-bg black
set-option -g default-terminal "screen-256color" #"xterm-256color" # "screen-256color"
set-option -g pane-active-border-fg green
############################################################################
# Status Bar
############################################################################
set-option -g status-utf8 on
set-option -g status-justify right
set-option -g status-bg black # colour213 # pink
set-option -g status-fg cyan
set-option -g status-interval 5
set-option -g status-left-length 30
set-option -g status-left '#[fg=magenta]» #[fg=blue,bold]#T#[default]'
# ? branch name >> ? Time Date CPU?
set-option -g status-right '#[fg=red,bold][[ #(git branch) branch ]] #[fg=cyan]»» #[fg=blue,bold]###S #[fg=magenta]%R %m-%d#(acpi | cut -d ',' -f 2)#[default]'
set-option -g visual-activity on
# Titles (window number, program name, active (or not)
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T'

Very wordy reference guide: https://www.dropbox.com/s/yae8pitov0ct4xf/tmux_p1_1.pdf?dl=0

Note: ctrl+b is the default prefix for entering commands. Similar to esc in vim.

Config

~/.tmux.conf To change the prefix to something easier:

unbind C-b # ctrl+b
set -g prefix C-a # ctrl+a

Starting

|------|------| | tmux new -s name | New Session |

Panes

|------|------| ctrl+b " | Split Horizontally ctrl+b % | Split Vertically exit | Close Pane ctrl+b <arrow key> | Move Between Panes ctrl+b o | Cycle Panes ctrl+b <space> | Cycle Pane layouts

Windows

|------|------| ctrl+b c | New Window ctrl+b <num> | Switch Between Windows - numbers are listen on the bottom in the green bar ctrl+b n | Next Window ctrl+b p | Prev Window ctrl+b , | Rename Window exit | Close Window ctrl+b w | Display Selectable List of Windows

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment