Tmux Basics

Installation

  • Arch: sudo pacman -S tmux

  • Ubuntu: sudo apt-get install tmux

  • MacOS: brew install tmux

Tmux Basic Elements

  • Session: Create a tmux workspace session
  • Window: Contain multiple panes
  • Pane: A window can be splited into multiple panes

Basic Commands

  • Check all Sessions: tmux ls
  • Create New Session: tmux new -s session-name
  • Create New Session without specific name(not recommended): tmux new
  • Disconnect from current session: tmux detach or ctrl + b + d
  • Reconnect the first session on the list: tmux a
  • Reconnect a specific session: tmux a -t session-name
  • Close current Window: exit
  • Shut down a session(and all programs in it): tmux kill-session -t session-name or ctrl + d to close everything

Shortcut Keys

  • Use ctrl + b as shortcut prefix: press ctrl b first, then press other keys
  • Help: ?
  • Display current time in current pane: t
  • Session Mgmt
    • List all sessions: s
    • Rename current session: $
    • Disconnect current session: d
  • Window Mgmt
    • Create a new window: c
    • Rename current window: ,
    • List all windows: w
    • Horizontal Split: %
    • Vertical Split: "
    • Select Next Window: n
    • Select Previous Window: p
    • Select No. 0-9 Window: 0-9
  • Pane Mgmt
    • Create horizontal pane: %
    • Create vertical pane: "
    • Check the index of current pane: q
    • Switch between panes: o
    • Switch the position with next pane: }
    • Switch the position with previous pane: {
    • Display current pane in the new window: !
    • Close current pane: x
    • Scroll through current Pane: [