Skip to content

Instantly share code, notes, and snippets.

@kaplan
Last active May 14, 2021 01:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kaplan/5229068 to your computer and use it in GitHub Desktop.
Save kaplan/5229068 to your computer and use it in GitHub Desktop.
My most commonly used tmux commands and reference sites for learning tmux

tmux handy commands and references

####sessions

tmux new -s session_name      # new session by name
tmux attach -t session_name     # attach session by name (you can also use a instead of attach)
tmux switch -t session_name     # switch session by name (you can also use a instead of attach)
tmux list-sessions              # list existing sessions
bind-key : new -s session_name  # new session from within a session  
// detach
tmux detach                     # detach currently attached session
bind-key :detach                # detach currently attached session
bind-key then hit d             # detach currently attached session

####bind key commands

#default bind key is ctrl+b, but you made it ctrl+a, then hit the following key to execute the command
bind-key ?      # list all key bindings. **This one is key**
bind-key s      # list and choose session
bind-key w      # list and choose window in session
bind-key $      # rename session
bind-key ,      # rename window
bind-key c      # new window within session
bind-key n      # change window within session
bind-key {      # swap pane -U
bind-key }      # swap pane -D
bind-key [      # enter copy mode and you can scroll with j k up down
bind-key q      # leave copy mode
bind-key x      # kill a pane with y/n
bind-key space  # next-layout (swap the split layout)
bind-key '      # give a command-prompt and you can input a window index or name
bind-key %      # Split the current pane into two, left and right.
bind-key "      # Split the current pane into two, top and bottom.

####input commands

bind-key : "break-pane"   # make a pane its own window 

####pane resizing

M denotes the meta key, usually bound to ALT.
On Macs the meta key is usually Esc. 
**In Terminal go Preferences > Keyboard and check 'Use option as meta key'** 
In iTerm2 go Preferences > Keyboard and check 'Use esc as meta key'


bind-key M-Up, M-Down, M-Left, M-Right # resize panes by 5 cells
C-b M-1   # vertical split, all panes same width
C-b M-2   # horizontal split, all panes same height
C-b M-3   # horizontal split, main pane on top, other panes bottom, vertically split, all same width
C-b M-4   # vertical split, main pane left, other panes right, horizontally split, all same height
C-b M-5   # tile, new panes on bottom, same height before same width

####references tmux man page
getting into tmux
http://www.dayid.org
hawkpost: tmux pt1
thoughbot: a tmux crash coarse
Bryan Liles tmux ramble
pane resizing superuser post
screencast pair programming with Tmux

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