Tmux Cheatsheet

September 13, 2017

panes My pane layout for playing single player asymmetrical tic tac toe.

We both know why you’re here. You wanna refresh your memory and look up a few commands. I wrote this cheatsheet for myself so that I could do the same. Make yourself comfortable. There’s a great book on tmux that you probably may want to check out.

The command Prefix

While we’re in a tmux session, we need to tell tmux that the command we’re about to send to it is destined for tmux indeed and not for the underlying application. The <ctrl+b> combination does just that. Since that is just a command prefix, you need to type in the actual command after that, hence why, in order to for example send a detach command, we need to press ctrl and b together, release those two, and after that press the command we want. People annotate it differently, I will stick to the C->d notation, where C is the command prefix, and whatever follows the arrow is the command.

Commands

Basics

  • tmux - start a new session
  • tmux new -s <session_name> - create a named session
  • exit or C->d - detach from a session
  • tmux ls - to list currently active sessionsA
  • tmux attach to attach to a session that’s running (if there’s only one)
  • tmux attach -t <session_name> - attach to a named session. (if you don’t know what sessions you have, run tmux ls)
  • tmux kill-session -t <session_name> - self explainatory
  • tmux new -s <session_name> -n <window_name> - create a session with a named first window
  • C->$ - rename current session. alt cmd: rename-session -t <current_name> <new_name>

Windows

  • C->c - create a new window (while in session)
  • C->, - rename current window
  • C->n, C->p - next window, previous window, respectively
  • C->[0..9] - select a window by number
  • C->w - display a selectable list of windows in the current session
  • C->& - kill window with a confirmation message
  • exit - while in multiple-window session, kill window

Panes

  • C->% - divide the current window (or pane) vertically
  • C->" - divide the current window (or pane) horizontally
  • C->o - cycle through panes
  • C->q - momentarily displays pane numbers in each pane
  • C-><arrow_key> - move around the panes in direction of <arrow_key>
  • C->spacebar - cycle through pane layouts
  • C->X - close pane. alt: just type exit

Command mode

  • C->: - enter command mode
  • new-window -n <name> "<command>" - create a new window named <name>, with <command> running immediately

Written by Daniel Kaczmarczyk, a software engineer and educator. you can find me on twitter or email me at daniel.kaczmarczyk@hey.com

a pale blue and yellow circle