Use tmux

What is tmux?

  • Tmux is a terminal multiplexer

    • You can start a Tmux session and then open multiple windows inside that session. Each window occupies the entire screen and can be split into rectangular panes.

      tmux sessions, windows, panes

      tmux sessions, windows, panes

  • With Tmux you can easily switch between multiple programs in one terminal, detach them and reattach them to a different terminal.

  • Tmux sessions are persistent

    • programs running in Tmux will continue to run even if you get disconnected. (Extremly useful when training neural netwoks on remoter server! 👏)
  • All commands in Tmux start with a prefix, which by default is ctrl+b.

Installation

On Ubuntu and Debian

sudo apt install tmux

On macOS

brew install tmux

Sessions management

CommandShortcutFunctionality
tmux new -s session_namecreates a new tmux session named session_name
tmux attach -t session_nameattaches to an existing tmux session named session_name
tmux switch -t session_nameswitches to an existing session named session_name
tmux list-sessions (tmux ls)lists existing tmux sessions
tmux detachprefix +ddetach the currently attached session
tmux renamesession -t 0 <new-name>prefix +$rename session 0 to <new-name>

Windows management

CommandShortcutFunctionality
tmux new-windowprefix + ccreate a new window
tmux select-window -t :0-9prefix + 0-9move to the window based on index
tmux select-window -t <window-name>move to the window <window-name>
tmux rename-window <new-name>prefix + ,rename the current window

Panes management

CommandShortcutFunctionality
tmux split-windowprefix + "create a new window
tmux split-window -hprefix + %move to the window based on index
prefix + xkill current pane

Cheatsheet

Tmux Cheat Sheet & Quick Reference

Reference