Skip to content

Instantly share code, notes, and snippets.

@rajvermacas
Last active August 21, 2025 22:56
Show Gist options
  • Select an option

  • Save rajvermacas/e14ca221f69b9dd73fe3ee6c46d2ea5e to your computer and use it in GitHub Desktop.

Select an option

Save rajvermacas/e14ca221f69b9dd73fe3ee6c46d2ea5e to your computer and use it in GitHub Desktop.
tmux

Here are the essential tmux commands to get you started:

Starting and Managing Sessions

  • tmux - Start a new session
  • tmux new -s sessionname - Start a new named session
  • tmux ls - List all sessions
  • tmux attach -t sessionname - Attach to a session
  • tmux kill-session -t sessionname - Kill a session
  • tmux kill-server - Kill the tmux server

Capture Output

tmux capture-pane -t ui -S -50 -p

Start logging the current pane to a file

tmux pipe-pane -t session_name -o 'cat >> session_name.log'
tmux pipe-pane -t session_name # to stop logging

Key Bindings (Default prefix is Ctrl+b)

Press the prefix key, then release it, then press the command key.

Session Management

  • Ctrl+b d - Detach from session
  • Ctrl+b s - List and switch sessions

Window Management

  • Ctrl+b c - Create new window
  • Ctrl+b n - Next window
  • Ctrl+b p - Previous window
  • Ctrl+b 0-9 - Switch to window by number
  • Ctrl+b , - Rename current window
  • Ctrl+b & - Kill current window

Pane Management

  • Ctrl+b % - Split vertically (side by side)
  • Ctrl+b " - Split horizontally (top/bottom)
  • Ctrl+b arrow keys - Navigate between panes
  • Ctrl+b x - Kill current pane
  • Ctrl+b z - Toggle pane zoom (fullscreen)
  • Ctrl+b { or } - Swap pane positions

Useful Shortcuts

  • Ctrl+b ? - Show all key bindings
  • Ctrl+b : - Enter command mode
  • Ctrl+b [ - Enter copy mode (use arrow keys to scroll, q to quit)

Common Workflow

  1. Start tmux: tmux new -s work
  2. Create windows for different tasks: Ctrl+b c
  3. Split panes as needed: Ctrl+b % or Ctrl+b "
  4. Detach when done: Ctrl+b d
  5. Reattach later: tmux attach -t work

These commands will cover most of your daily tmux usage!

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