Shohei Kameda
Posted on January 3, 2022
This article is the 4th day of the Advent Calendar 2021 of Wazaterm, an online Linux terminal for hackers.
Wazaterm comes with tmux installed by default. tmux is software that
- Tmux stands for “Terminal Multiplexer.”
- It allows you to split a Linux-style terminal screen into multiple sessions, windows, or panes.
- A terminal can have multiple sessions.
- A single session can have multiple windows.
- A single window can have multiple panes.
- The session is maintained even when the terminal is closed. You can avoid the tragedy of running a command and then getting logged out and ending up with no command result.
Tmux maintains the session, which is essential to open an editor and develop it remotely. It’s hard to set it up every time you connect. Please image if you use windows or mac, every time you unlock the screen, you need to relaunch the software or apps and adjust/arrange the window size and location. This can not be done.
And in the case of browsers, some OS will immediately kill the session when the main page goes to background (yes, it’s iPad!
So, since it is an indispensable tool in the server-side world (some people may be using “screen” for similar functions), I think there is no harm in learning how to use it.
In this article, I would like to explain the minimum necessary settings.
All operations are done with the keyboard only (cool, like a hacker!). It is necessary to distinguish it from regular input. This is why we have the prefix, which is an alphanumeric character that can be typed after the prefix to call a tmux action.
The prefix; default is ctrl-b. Here are some excerpts of the actions I often use.
- Ctrl-b c Create a new window (Create)
- Ctrl-b number Go to the window specified by the number
- Ctrl-b n Go to the next window (Next)
- Ctrl-b p Go to the previous window (Prev)
- Ctrl-b & Exit to window name (with confirmation)
- Ctrl-b “ Split pane vertically
- Ctrl-b % Split pane left/right
- Ctrl-b o Move to the next pane
- Ctrl-b ? Show list of key bindings (q to return)
Tmux allows you to add plugins by using tmux-plugin/tpm freely. I’m using the
- tmux-plugins/tmux-sensible - configures settings that everyone else uses (saves you the trouble of extra configuration)
- arcticicestudio/nord-tmux - theme
- tmux-plugins/tmux-resurrect - Save your session. You can also reboot from there. If you lose all your tmux sessions because of a reboot, you can restore the whole saved session.
Once you learn about 10 of these, you’ll be able to use them freely! Let’s take this opportunity to learn how to use them.
Posted on January 3, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.