Tmux
What is tmux?
Tmux is what’s called a terminal multiplexer. Essentially, it lets you split one terminal window, into multiple similar to how a your desktop interface lets you use multiple windows at once. It has more features than that, but the multiplexing is what this article is going to focus on.
How to use tmux
You can launch tmux with the tmux
command.
Tmux works by using a prefix key, which you enter first, before entering another key to enter a command. By default, this prefix key is Cntrl + B.
Window control
Tmux’s most basic and essential feature is creating more windows. First, input the prefix key (default is control + b), and then another key to tell tmux to do something:
key | action |
---|---|
c | create new window |
p | previous window |
n | next window |
0, 1, 2, … | go to specific numbered window |
& | kill window |
Copy/Scroll mode
Because you can’t scroll normally in tmux, you have to enter a special scroll mode with prefix + [. In this scroll mode, you can use q to quit, Control S to search down, and Control R to search upwards. After searching, n goes to the next item, and Shift+n goes to the previous one. q exits search.
Attatch/Detatch
D
detaches.
You can list active sessions with tmux ls
tmux attach -t [sessionnumber]
to reattach. Or tmux a
for a shorter verb.