Tmux is a terminal multiplexer. From its website:

It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.

To get started type tmux in your terminal and a new session will open.

ss-tmux4
A screenshot from https://tmux.github.io

The thing I like the most is the ability to detach and re-attach terminals, just like screen does. Basically, if for instance you are working on a remote machine via ssh and you have a long task running or your connection drops, you can detach your session and let the task run on the remote machine in the background. Once you can get back to it you re-attach the terminal and you’ll be right where you left.

To detach hit Ctlr-B + d. Once you’re back at your terminal you can list all the running sessions with

$ tmux ls
0: 1 windows (created [date])
1: 1 windows (created [date])(attached)

Kill or attach to one:

$ tmux kill-session -t session-name
$ tmux a -t session-name

Second great feature is having multiple windows on the same session and splitting them into panes, much like Terminator (and screen again) if you wonder.

Having many windows (better call them workspaces?) is handy to avoid opening lots of ssh sessions at once, or filling your desktop with actual terminal windows. Create and manage them as follows:

Ctrl-B + c create a new window
Ctrl-B + n/p next/previous window
Ctrl-B + w choose window

 

Panes are instead useful for editing files side by side (like splitting a text editor), keeping top running in sight or, just like windows, working on two different tasks in the same terminal.

Ctrl-B + “ split vertically
Ctrl-B + % split horizontally
Ctrl-B + x close pane
Ctrl-B + ARROW_KEY select pane

 

You can get the full list of shortcuts by hitting Ctrl-B + ?.

Share and comment!


Source: man page (online version)

Advertisements