tmux
is self-described as “A Terminal Multiplexer”. What the crap
does that mean?! tmux
is a window-manager for your terminal. It allows you to have multiple
“panes” (windows) on the screen at once, as well as multiple tabs.
Many terminal apps (I use iTerm2) have similar functionality, but I prefer to
use a system which can work both locally and remotely. I can remote into a machine, run tmux
, and
have all the same functionality I’m used to having locally.
I use tmux
every day so that I can have multiple files open on the same screen or to have
a command running along-side (or below, or behind, etc) the terminal I’m working in.
You operate tmux by using a <leader>
key followed by a command key. I use Ctrl+b for
my leader. For example, to zoom a pane to fill the current tab, I would hit Ctrl+b
z (note that I let go of Ctrl before hitting z)
Useful Commands
There are a few default commands I use every day which were not presented in my initial walk through:
Add <leader>
before each of these!
- z - Zooms the current pane to full-size. Same combo restores the window.
- q - Overlay pane-numbers on the screen. If you’re quick, you can hit the pane-number to switch to that pane.
- b - Switch to the last-used pane. Useful in combo with q.
- Space - Re-arrange your windows. Hit a few times to cycle through options.
- Dangerous! - There is no way to go back if you customized the size of your windows.
- { / } - Swap the position of the current pane with the previous / next pane.
- [ - Freeze the current pane, and navigate around it.
- Useful for scrolling back up off the screen with arrows / Page Up / Page Down.
- Hit Space to turn on highlighting. Highlight some text and hit Enter to copy. Use ] to paste.
- Hit m to mark a pane.
- Hit M to un-mark a pane.
- Send keys to marked pane with:
tmux send-keys -t'{marked}' "echo foo" Enter