Table of Contents

General Usage

  • tmux version

    1
    2
    
    $ tmux -V
    tmux 2.9a
    
  • Start a tmux session with

    1
    2
    3
    4
    
    tmux
    tmux new
    tmux new -s mySessionName -n myWindowName
    # alias: new | new-session
    
  • Attach to a tmux session:

    1
    2
    3
    
    tmux a                # attach to last session
    tmux a -t mysession
    # alias: a | at | attach | attach-session
    
  • List tmux sessions:

    1
    2
    3
    
    tmux ls
    tmux list-sessions
    # alias: ls | list-session | list-sessions
    
  • Kill Session:

    1
    
    tmux kill-session -t mySessionName
    

Shortcuts

Key(s) Description
CTRL+b <command> sends <command> to tmux instead of sending it to the shell
General Commands
? shows a list of all commands (qcloses the list)
: enter a tmux command
Working with Windows
c creates a new window
, rename current window
p switch to previous window
n switch to next window
w list windows (and then select with arrow keys)
Working with Panes
% split window vertically
- split window horizontally requires bind - split-window -v in our .tmux.conf
go to right pane
go to left pane
go to upper pane
go to lower pane
Working with Sessions
d detach from session

Scripting tmux

Starting multiple commands in multiple panes

Start a new tmux session with tmux before running the script!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# start a new tmux session and detach from it
tmux new-session -d -s session1

tmux rename-window 'my window'
tmux send-keys 'echo "pane 1"' C-m

tmux select-window -t session1:0
tmux split-window -h
tmux send-keys 'echo "pane 2"' C-m

tmux split-window -h
tmux send-keys 'echo "pane 3"' C-m

# we want to have notifications in the status bar, if there are changes in the windows
tmux setw -g monitor-activity on
tmux set -g visual-activity on

tmux select-layout even-horizontal

# select the first window to be in the foreground
tmux select-window -t session:1

# attach our terminal to the tmux session
tmux -2 attach-session -t cflogs

Configuring tmux

You can configure tmux via the ~/.tmux.conf file. After making changes to the config file, you can update the configuration “on-the-fly” with

1
  tmux source ~/.tmux.conf

Further Resources