Tmux
April 20, 2021 | StackThere are two popular tools for working with screens/sessions in the terminal; Screen and Tmux. Screen is probably to consider the most native and simple of the two. But, this post will be about the Tmux application.
It does not come as native in contrary to Screen, so you have to install it:
sudo apt install tmux
Start a new Tmux session:
tmux
After this, all commands to Tmux starts with "Ctrl + b"
Start out by getting a list of all commands:
Ctrl+b ?
When creating new sessions, it can be nice to organise them by names instead of the default numerical session names:
tmux new -s session_name
Detach from current session:
Ctrl+b d
List all sessions:
tmux list-sessions
Attach to a session:
tmux a -t [name or number]
To kill panel and in the end the session (if only one panel left):
ctrl+b x
To kill sessions:
tmux kill-session -t [my-session]
or all sessions
tmux kill-server
Working with Windows and Panes
Windows are to be considered as workspaces/tabs. Let's say you have a window called "Dev" and another called "Research".
Panes are visible work areas within the windows.
By default a Window (named 0) is created when you create a new session.
Windows:
Change the name of the current Window:
Ctrl+b ,
To create a new Window:
Ctrl+b c
To navigate between Windows:
Ctrl+b [n or p]
At the bottom bar you can see all Windows listed and "*" for the active Window.
Close current Window:
Ctrl+b &
Panes
Split current Window horisontally in to Panes:
Ctrl+b %
and vertically:
Ctrl+b "
Navigate between panels:
ctrl+b [and arrows]