tmux cheatsheet

İbrahim Akalın

2024/01/06

Background

tmux is a terminal multiplexer that has many practicalities. I haven’t been using it extensively so whenever I get back to it for some reason, I need to look up things. There are quite a number of cheatsheets and other sort of resources online but I wanted to compile a cheatsheet for myself and improve it in time so that I spend less and less time looking up. This is the silly story of how this cheatsheet came to be.

Having a .tmux.conf file

You don’t know when you may need to overwrite a default configuration of tmux. I think it’s a good idea to create a .tmux.conf file in your home directory.

Mouse mode

tmux has the option to enable mouse mode. If you’d like to enable mouse mode permanently, add the following line to your .tmux.conf file but do it with knowing limitations:

set -g mouse on

Now you can switch between your panes and windows using your mouse. You can resize panes as well.

NOTE: However, you will run into issues when copying and pasting texts. With mouse mode on, your selections will behave differently, you won’t be able to cmd+c to copy the selected text into the system clipboard. Rather, when you select a text by dragging your mouse and then release it, tmux will automatically copy the text into the buffer. To paste it, you need to do (ctrl+b) then ], it’s not the same thing as what you have in the system clipboard which you can paste with cmd+v. So then how to paste what we have in tmux’s buffer into somewhere else outside tmux? At this point, things are getting complicated and I’d like to not include those in this cheatsheet. Several solutions are available around, do your own research.

Windows

Panes

To navigate through the history of a tmux pane/windows you need to:

To search for a term in pane/windows history:

  1. Enter copy mode either with (ctrl+b) then [ or scrolling with mouse (if enabled)
  2. Use ctrl+s and type the term you want to search when prompted. To keep searching, keep pressing ctrl+s.

History limit

There is a limit to the number of lines you can scroll back and search. In tmux, the defualt is 2000 lines. For me, this was not enough in most cases, so I prefer to increase it. To increase this limit, to 8000 let’s say, you can add the following line to your .tmux.conf file:

set-option -g history-limit 8000

Note that a high value limit can strain the memory if you’re creating a lot of panes/windows.

More?

This is it for now. This cheatsheet is definitely not complete but it’s a good start. I want to add more and improve it in time until it’s not noisy but also not lacking any essentials.

Further resources


  1. You can, indeed, just write exit to close/kill a window or a pane but you never know when you’ll have a hanging process and there are more things you may have difficulties with exiting other than vim↩︎ ↩︎

  2. For some reason, resizing my vertically split panes was working but the other one wasn’t. I haven’t spent much time on the issue but mouse mode helped here. ↩︎

Table of Contents