Tuesday, December 09, 2014

tmux crash course

So you've probably heard about tmux and want to get started.  It might sound intimidating but after you follow this tutorial, you'll find that it's really not that bad.

Here's a basic crash course, written so that you can follow along, step-by-step.

Installation on OS X

brew install tmux

Basic commands

tmux new-session -s foo

Creates a session named foo.

Congrats! You are now attached to a session and you should see one tmux window.

A bit of terminology: you create a session which can have one or more windows, which we'll see below. Within a window, you can split it into panes.

(I'll use ^ to indicate "Ctrl", so ^b means Ctrl+b)

^b c
will create a new window.  You should see a status bar at the bottom of your terminal listing out the current windows. Do it again to create another.

Now you have multiple ways to switch between windows:

^b 1  switches to window 1
^b 2  switches to window 2
^b p  previous window
^b n  next window
^b w  choose window from a list
^b l  (lower case "L") go to last selected window

Next, you probably want to split your current window into panes.
^b "   Split vertically
^b %   Split horizontally

To switch panes:
^b o   Go to the "next" pane
^b up   Go to the pane above. Try left, right, and down as well.

Here's a cool feature of tmux that you might be familiar with if you've ever used screen.  You can detach from a session and reattach at a later time, with all of your windows and panes intact!
^b d .   Detach from current session

Finally, to reattach to a session
tmux attach -t foo   Reattach to a session named foo

Hope you found this to be useful.  Please let me know if you have any questions. Thanks!

No comments: