Cyrus Stoller home about consulting

Getting started with tmux

One of the biggest benefits I’ve seen from switching to vim as my primary text editor is that I can use the same text editor whether I ssh into a server, or I use any of my laptops (regardless of operating system). If you’re interested in learning how I use vim, please check out this old post. To keep my workflows as similar as possible, I have also started gravitating to tmux. This post should offer some tips on how to get started with tmux.

For this tutorial, I’ll use the following notation:

If you’ve used emacs before, you’ll find that a lot of the keybindings bear some resemblance. Let’s get started.


Part 1: Core concepts

Using sessions:

When you start a new tmux session, a single window with a single pane is created.

This is the end of Part 1 on core concepts.


Part 2: Navigation

Now that you have a tmux session, you need to setup up your work environment.

Managing windows:

Managing panes:

Resizing and moving panes:

This is the end of Part 2 on navigation.


Part 3: Configuration

Like with a vimrc, you can add configurations to your tmux.conf. Here are some that you may consider adopting when you’re getting started. To learn more, you can browse the docs.

# tmux.conf
set -g mouse on           # enable mouse scrolling
set -s escape-time 10     # faster command sequences
set -g history-limit 5000 # boost history limit
set -g allow-rename off   # don't rename windows automatically

set -g mode-keys vi       # use vi keybindings for copy mode

# display "tmux.conf loaded!"

This is the end of Part 3 on configuration.


Part 4: Data movement

A key hurdle to me adopting a tmux-based workflow was figuring out how to move data between panes. Now that I know how to use it, I find it much more expressive than using my mouse to select text, and I appreciate having easy access to multiple buffers.

emacs mode (default)

vi mode (my preference)

Multiple paste buffers

Copied text is placed into a buffer that you can paste later. tmux has the ability to manage multiple buffers. Here are the highlights of how I use them.

You can read more about copy and paste in tmux here.

This is the end of Part 4 on data movement.


Conclusion

Hope this helps get you oriented with tmux. For a quick refresher about the commands at your disposal, use prefix ?. For more details, I will sometimes browse through $ tmux list-keys to see all of the available keybindings and $ tmux list-commands to see all of the commands that can be used. I realize this is just scratching the surface of how tmux can help improve my workflow. If you have suggestions on things that I should consider trying, please let me know. Happy hacking.

Category Tutorial