Cheat Sheet :: Tmux

Working with Sessions

New Session

  • Start a New Session

    $> tmux new-session
    
  • Or you can type

    $> tmux
    
  • Or you can use the shorthand

    $> tmux new
    
  • If you’re already inside the tmux

      : new
    
  • Start a New Session with the name mysession

    $> tmux new -s mysession : new -s mysession
    

Kill/Delete Sessions

  • Kill/Delete mysession

    $> tmux kill-session -t mysession
    
  • Or you can use the shorthand

    $> tmux kill-ses -t mysession
    
  • Kill/Delete all sessions but mysession

    $> tmux kill-session -a -t mysession
    
  • Kill/Delete all sessions but the current session

    $> tmux kill-session -a
    

Rename session

  • If you’re already inside the tmux

    Ctrl + b + $
    

Move Between Sessions

  • Move to Previous Session // If you’re already inside the tmux

    Ctrl + b + (
    
  • Move to Next Session // If you’re already inside the tmux

    Ctrl + b + )
    

Attach to an Existing Session

Attach to the Last Session

$> tmux attach-session
  • Or

    $> tmux attach
    
  • Or

    $> tmux at
    
  • Or you can use the shorthand

    $> tmux a
    

Attach to an Existing Session with the Name mysession

$> tmux attach-session -t mysession
  • Or

    $> tmux attach -t mysession
    
  • Or

    $> tmux at -t mysession
    
  • Or you can use the shorthand

    $> tmux a -t mysession
    

Detach from Session

  • If you’re already inside the tmux

    Ctrl + b + d
    

Show ALL sessions

  • Listing ALL sessions

    $> tmux list-sessions
    
  • Or you can use the shorthand

    $> tmux ls
    
  • If you’re already inside the tmux

    Ctrl + b + s
    

Working with tmux Window

Start a new Window

  • Start a new session with the name mysession and window name mywindow

    $> tmux new -s mysession -n mywindow
    
  • Create a new Window // If you’re already inside the tmux

    Ctrl + b + c
    

Rename a Window

  • Rename current window

    Ctrl + b + ,
    
  • Close the current window

    Ctrl + b + &
    

Moving Between Windows

  • Previous window

    Ctrl + b + p
    
  • Next window

    Ctrl + b + n
    
  • Select window by number

    Ctrl + b + 0...9
    

Reorder a Window

  • Swap window number 2 and 1

      : swap-window -s 2 -t 1
    

Working with Panes

Toggle Panes

  • Toggle last active pane

    Ctrl + b + ;
    

Split the Pane

  • Split pane vertically

    Ctrl + b + %
    
  • Split pane horizontally

    Ctrl + b + "
    

Moving Between Panes

  • Move the current pane to the left

    Ctrl + b + {
    
  • Move the current pane t the right

    Ctrl + b + }
    

Switching Between Panes

  • Switch to pane to the direction

    Ctrl + b + ⬆
    Ctrl + b + ⬇
    Ctrl + b + ⬅
    Ctrl + b + ⮕
    

Toggle synchronize-panes

  • Send the same command to all panes

      : setw synchronize-panes
    

Toggle Between Panes

  • Toggle between pane layouts

    Ctrl + b + <SpaceBar>
    
  • Switch to next pane

    Ctrl + b + o
    
  • Show pane numbers (Type the number to go to that pane)

    Ctrl + b + q
    

Toggle the Pane Zoom

Ctrl + b + z

Convert a Pane into a Window

Ctrl + b + !

Resize the Pane

  • Resize the current pane height

    Ctrl + b + ⬆
    Ctrl + b + ⬇
    
  • Resize the current pane width

    Ctrl + b + ⬅
    Ctrl + b + ⮕
    

Close the Pane

  • Close the Current Pane

    Ctrl + b + x
    

Enter in Copy Mode (Buffer)

  • Enter in Copy Mode

    Ctrl + b + [
    
  • Enter in Copy Mode and Scroll One Page Up

    Ctrl + b + PgUp
    
  • Quit Mode

      q
    
  • Go to Top Line

      g
    
  • Go to Bottom Line

      G
    

Scroll using the Keyboard Cursor (Arrows)

  • Scroll Up

    Keyboard Up Cursor //
    
  • Scroll Down

    Keyboard Down Cursor //
    
  • Scroll Left

    Keyboard Left Cursor //
    
  • Scroll Right

    Keyboard Right Cursor //
    

Scroll using the vim keys

FIRST: Remember to Set the vim keys in Buffer Mode. Go to Set the runtime tmux Options section to learn more.

  • Move Cursor to the Left

      h
    
  • Move Cursor Down

      j
    
  • Move Cursor to the Up

      k
    
  • Move Cursor to the Right

      l
    
  • Move Cursor Forward One Word At a Time

      w
    
  • Move Cursor Backward One Word At a Time

      b
    
  • Search forward

      /
    
  • Search backward

      ?
    
  • Go to the Next Keyword Occurrence

      n
    
  • Go to the Previous Keyword Occurrence

      N
    

Working with Buffers

  • Start a Selection

      <SpaceBar>
    
  • Clear the Selection

      <Esc>
    
  • Copy selection

      <Enter>
    
  • Paste the Contents of Buffer_0

    Ctrl + b + ]
    
  • Display the Buffer_0 Contents

      : show-buffer
    
  • Copy the Entire Visible Contents of Pane to a Buffer

      : capture-pane
    
  • Show All Buffers

      : list-buffers
    
  • Show All Buffers and Paste Selected

      : choose-buffer
    
  • Save the Buffer Contents to the file buf.txt

      : save-buffer buf.txt
    
  • Delete the Buffer_1

      : delete-buffer -b 1
    
  • Enter the Command Mode

    Ctrl + b + :
    

Set the runtime tmux Options

  • Set OPTION for All Sessions

      : set -g OPTION
    
  • Set OPTION for All Windows

      : setw -g OPTION
    
  • Set to use vim keys in Buffer Mode

      : setw -g mode-keys vi
    
  • Set the vim Buffer Size in Runtime (history)

    set-option -g history-limit 50000
    
  • Start a New Session with a Defined Buffer Size (history)

    tmux set-option -g history-limit 50000; new-session
    

Help

  • Show Every Session, Window, Pane, etc…

    $> tmux info
    
  • Show Shortcuts

    Ctrl + b + ?