If you use Linux, and have multiple terminal windows open on your desktop, read on.
Thanks to Randall Degges who gave an introduction to tmux.
Splitting your terminal – use a a multiplexer
tmux is what’s called a terminal multiplexer.
tmux is a program you can run in your terminal. It allows you to have multiple terminal “windows” running in the one terminal window in your windows manager.
You can also split each terminal window into several panes.
This is useful if you find yourself opening multiple terminal windows.
I’m a tmux noob, so I still wasn’t sure where to start with tmux, so here’s how I got going.
The secret for using tmux
When running tmux, press
Ctrl b (Linux). And then enter your tmux command.
For a list of commands, check
I was confused by
man tmux where it referred to
C-b. It does explain that this means typing
Ctrl b followed by command you desire.
Ok, let’s get started with tmux
- Open a terminal window (Ctrl Alt t)
tmux. If the program is not installed, install it. On Debian-based systems you’ll be told how to install it with an
- Now an instance of tmux is running in your terminal. Notice the coloured toolbar at the bottom of the window which tmux will use to keep you informed.
Split the terminal window into two panes
man tmux tells us that the command
" splits the current pane into two, top and bottom.
This means that you first press Ctrl b, and immediately followed by typing
Great. You now have two terminal panes to work in.
From now on I’ll use the standardised C-b notation, which means typing Ctrl b.
Open the man page in the current pane
Now you have the tmux man page in one pane, and your standard terminal in the other pane. You should be starting to see the usefulness of tmux.
You can’t just use your mouse to click into the pane you want to use.
An easy way to cycle between panes in your current window is:
Kill a pane
To kill the current pane:
y to confirm.
A task for you:
- Read the man page to find out how to split a pane vertically rather than horizontally.
- Split the window into two panes once again.
Create a new windows
So far, we have been dealing with one tmux window, with multiple panes.
You can also have multiple windows, with multiple panes. I consider a window like a desktop, or a browser tab.
Create a second window:
Check the bottom toolbar. You’ll see your two windows (0 and 1) listed.
Rename your window
Make it easier to identify windows by typing:
(Yes, that’s a comma.)
Now type a short name to identify this window.
Switch between windows
No Alt-Tab here!
C-b and then the number of the window you want to open.
Try switching between window 1 and 0 and back again:
Cycle to the next window
Or cycle to the previous window:
List all keybindings
As the man page tells you, issue this command to quickly review the available keybindings:
Ctrl b ?
Stuff I still need to learn with tmux
- How to scroll through the history of the current pane. I’m used to being able to scroll up with the mouse wheel. There must be another way to scroll, presumably with a keyboard shortcut.
- Sessions: I know there is functionality to remember the layout of your windows and panes for the next time you run tmux.
- Automatically launching tmux for each new terminal: once I get used to tmux, I guess I’ll want to have it launched automatically (?).
Other terminal multiplexer options
If you’ve ever had the need to run multiple terminal windows inside an existing terminal window, you’ve probably heard of GNU screen.
Unfortunately, I hadn’t.
Ok, to be more honest, I had read about screen one week before reading his blog post.
But I had been using Linux for three years before realising you could even split your terminal window.
Enjoy tmux. Was this quick run-down of help to you? What other commands have you found useful?