tmuxtutor / basics

A brief tmux tutorial inspired by vimtutor

Download as .zip Download as .tar.gz View on GitHub

tmuxtutor.basics

Welcome to tmuxtutor!

Prefix key

For every command in tmux you have to type a PREFIX. By default, this is

  CTRL-b

Before we start: To get back from a tmux dialogue or display, you can use

  q

or

  ESCAPE

Sometimes you get error messages, and they will only be displayed for a second. To see the last error messages, type

  PREFIX + ~ (tilde)

Basic commands

Ok, let's try our first command.

To show the current time, type

  PREFIX + t

That is, type the PREFIX and then t. But it also works if typed all at the same time.

To get a list of all keys that are bound to a command, type

  PREFIX + ?

Every key is listed with the exact command it is bound to. All available commands are listed in the man page.

To close this or other tutorials, just type

  q

which will end the less and close the window.

Command line

The most used commands are mapped to keys, but sometimes you need to call other commands or commands with other options.

The t key is mapped to the clock-mode command, and you can call that manually with the command prefix :. Let's try it:

  PREFIX + :clock-mode + Enter

tmux supports tab completion; unfortunately it doesn't show you all possibilities, so you have to type until it's unambiguous:

  :clo<TAB>

Another possibility is to type the command into your shell:

  % tmux clock-mode

This will enter the clock mode in your tmux session. If typed from within a session, it will do this right were you are. If you type this from another shell not running tmux, it will choose the most recent used tmux session, window and pane for the command. Try it out!

You can also specify a target session:window:pane with -t.

  % tmux clock-mode -t play:0.1 # session 'play', window 0, pane 1

The tab completion for this (tmux <command> and tmux command -t <target>) in zsh is really advanced.


Sessions

tmux has sessions. A session can have several windows, and a window can have several panes.

This tutorial is started as a session called "demo" which you should be able to see in the status bar at the bottom.

You can detach a session by typing

  PREFIX + d

You will be back in the shell where you started the session.

To reattach to this session, type

  tmux attach -t demo

If there is only one session, you can omit the -t option.

  tmux ls
  tmux list-sessions

will list all your tmux sessions.