Windows: tabs inside a session

tmux · Essentials · 7 min

Windows let one session hold your editor, server, logs and shell side by side without extra terminal tabs.

A session contains one or more windows, each filling the whole screen, like tabs. The status bar at the bottom lists them as 0:bash* 1:logs-, where * marks the current window and - the previous one.

Default key bindings:

  • C-b c creates a new window.
  • C-b n / C-b p go to the next / previous window, C-b 0...C-b 9 jump by number, C-b l toggles to the last used window.
  • C-b , renames the current window. Good names (editor, server, db) make the status bar useful.
  • C-b w opens an interactive tree of all sessions and windows with previews; arrows and Enter pick one.
  • C-b & kills the current window (after confirmation).

By default tmux renames windows automatically after the running program (vim, ssh); renaming one by hand switches that off for that window.

From the shell or the command prompt the same operations are commands: new-window -n logs, select-window -t 2, rename-window db, kill-window. Windows are numbered from 0; many people set base-index 1 so numbering matches the keyboard (see configuration).

Example

# inside tmux:
#   C-b c     new window
#   C-b ,     rename it (e.g. 'server')
#   C-b 0     jump to window 0
#   C-b l     back to the last window
#   C-b w     pick from a tree of sessions/windows
tmux new-window -n logs 'tail -f /var/log/syslog'   # from a shell
tmux select-window -t logs

Remember

  • C-b c new, C-b n/p next/previous, C-b <number> jump
  • C-b , renames; C-b w shows everything as a tree
  • Status bar: * = current window, - = previous

Check yourself

  1. Which key opens an interactive chooser of all sessions and windows?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: github.com/tmux/tmux/wiki/Getting-Started