Bash - Tmux


Terminal Multiplexer. Used to open a lot of sessions in a single window. Can create tabs and split a window into multiple parts. Tmux sessions stay active even after closing a connection (ssh), so it is a handy way to keep your work or have running process run in the background when you're not connected to the host.

My personal ".tmux.conf" file can be found HERE. My plugin install script can be found HERE.

Commands

To enter command mode: Ctrl + b, :

Copy Mode

  • Ctrl + b, [: Enter copy mode
  • Use vim navigation keys or arrow keys to move around
  • Space: Start selecting
  • Esc: Clear selection
  • Enter: Copy selection
  • Ctrl + b, ]: Paste

Panes

  • Alt + ← ↑ → ↓: Switch to pane
  • Ctrl + b, v: Split plane vertically
  • Ctrl + b, s: Split plane horizontally
  • Ctrl + b, {: Move the current pane left
  • Ctrl + b, }: Move the current pane right
  • Ctrl + b, Space: Toggle between pane layouts
  • Ctrl + b, z: Pane zoom
  • Ctrl + b, !: Convert pane into a window
  • Ctrl + b + ← ↑ → ↓: Resize pane. Hold down the first to keys and tap the arrow key
  • Ctrl + b, x: Close current pane

Plugins

Tmux plugin manager: TPM

  • Ctrl + b, Ctrl + I: Install plugins
  • Ctrl + b, Ctrl + U: Update plugins

Tmux Resurrect: Restore tmux environment after system restart.

  • Ctrl + b, Ctrl + s: Save
  • Ctrl + b, Ctrl + r: Restore
  • Saved sessions are stored in ~/.tmux/resurrect/. With continuum the tmux environment is saved every 15 minutes. Every once in a while, saved sessions need to be purged.
  • To restore a previously saved session as the current session: ln -sf <desired resurrect> last. Will need to restore restore the session afterwards.

Sessions

  • Start a new session:
    $ tmux
  • Kill a session:
    $ tmux kill-session -t <session name >
  • Rename a session: Ctrl + b, $
  • Detach (leave) from session: Ctrl + b, d
  • List sessions:
    $ tmux ls
  • Enter an existing session:
    $ tmux a -t <session name>
  • Ctrl + b, r: Reload .tmux.conf file

Windows

  • Shift + ← →: Switch to window
  • Ctrl + b, c: Create a new window
  • Ctrl + b, ,: Rename window
  • Ctrl + b, &: Close current window
  • Ctrl + b, 0 ... 9: Select a window by number
  • Ctrl + b, : :swap-window -s <source window number > -t <target window number>: Create a new window