Getting started with tmux
I started learning tmux and highly recommend the book tmux: Productive Mouse-Free Development 1 as a guide. My
tmux.conf 2 configuration file is available as well.
Ctrl-bis the default prefix which I kept so that I could continue to use
Ctrl-ato move the cursor to the front in bash and vim.
- On OS X I remapped my caps lock key to be the control key
Ctrl-b zcan be used to toggle a pane into a window, and back to a pane.
- To scroll back through output
Ctrl-b [enters copy mode. I use vim navigation to move around (
Ctrl-dup and down 1/2 page,
Shift j/kto move a line at a time). If I know I need to read back though, I usually tail the log file in a separate terminal window and use the mouse since I find it to be faster.
tmux lswhen detached, lists any running tmux sessions.
tmux attach -t Xcan be used to attach to an existing session, where X is the number of the session.
Ctrl-b ddetaches from an existing session
Ctrl-b ccreates a new window within a session.
exitwill close the window.
Ctrl-b ,(comma) can be used to rename the window.
- To split a window into panes, following the guidelines the book recommends, the shortcut
Ctrl-b |(pipe) splits the window vertically into two panes next to each other, while
Ctrl-b -(hyphen) splits the window into two panes stacked on top of each other horizontally. To move back and forth between panes
Ctrl-b h/j/k/lcan be used, or to apply a new layout entirely to the panes within a window,
Ctrl-b spacebarcan be used.
Ctrl-b wdisplays a list of the open windows, and the h/j/k/l keys can be used to move up and down the list.
Ctrl-b Xwhere X is a number can be used to jump to a specific numbered window.
One of the issues when resizing a window from a small size to a large size is that dots would be drawn around the main content area. Detaching and re-attaching to the window seems to fix it. 3
At this time it is not possible to give names to panes within windows. I tried having multiple applications running with their log file being tailed, one application per pane within a window, but it became too difficult to tell what application was running in a given pane. As a workaround I mostly limit a window to a single running application, and don't use multiple panes.
Do you have any favorite tmux tips or tricks? Please get in touch.