Make Tmux Pretty and Usable (2024)

Article URL: https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ Comments URL: https://news.ycombinator.com/item?id=47752819 Points: 222 # Comments: 160

Make Tmux Pretty and Usable (2024)
Make Tmux Pretty and Usable (2024) Photo: Hacker News

In my previous blog post I gave a quick and easy introduction to tmux and explained how to use tmux with a basic configuration.

If you’ve followed that guide you might have had a feeling that many people have when working with tmux for the first time: “These key combinations are really awkward!”.

Rest assured, you’re not alone.

Judging from the copious blog posts and dotfiles repos on GitHub there are many people out there who feel the urge to make tmux behave a little different; to make it more comfortable to use.

Probably the most common change among tmux users is to change the prefix from the rather awkward C-b to something that’s a little more accessible.

Personally I’m using C-a instead but note that this might interfere with bash’s “go to beginning of line” command 1 .

On top of the C-a binding I’ve also remapped my Caps Lock key to act as Ctrl since I’m not using Caps Lock anyways.

This allows me to nicely trigger my prefix key combo.

To change your prefix from C-b to C-a , simply add following lines to your tmux.conf :
Another thing I personally find quite difficult to remember is the pane splitting commands.

" to split vertically and % to split horizontally just doesn’t work for my brain.

I find it helpful to have use characters that resemble a visual representation of the split, so I chose | and - for splitting panes horizontally and vertically:
Since I’m experimenting quite often with my tmux.conf I want to reload the config easily.

This is why I have a command to reload my config on r :
Switching between panes is one of the most frequent tasks when using tmux.

Therefore it should be as easy as possible.

I’m not quite fond of triggering the prefix key all the time.

I want to be able to simply say M- to go where I want to go (remember: M is for Meta , which is usually your Alt key).

With this modification I can simply press Alt-left to go to the left pane (and other directions respectively):
Although tmux clearly focuses on keyboard-only usage (and this is certainly the most efficient way of interacting with your terminal) it can be helpful to enable mouse interaction with tmux.

This is especially helpful if you find yourself in a situation where others have to work with your tmux config and naturally don’t have a clue about your key bindings or tmux in general.

Pair Programming might be one of those occasions where this happens quite frequently.

Enabling mouse mode allows you to select windows and different panes by simply clicking and to resize panes by dragging their borders around.

I find it pretty convenient and it doesn’t get in my way often, so I usually enable it:
Stop Renaming Windows Automatically
I like to give my tmux windows custom names using the , key.

This helps me naming my windows according to the context they’re focusing on.

By default tmux will update the window title automatically depending on the last executed command within that window.

In order to prevent tmux from overriding my wisely chosen window names I want to suppress this behavior:
Changing the colors and design of tmux is a little more complex than what I’ve presented so far.

As tmux allows you to tweak the appearance of a lot of elements (e.g.

the borders of panes, your statusbar and individual elements of it, messages), you’ll need to add a few options to get a consistent look and feel.

You can make this as simple or as elaborate as you like.

Tmux’s man page (specifically the STYLES section) contains more information about what you can tweak and how you can tweak it.

Depending on your color scheme your resulting tmux will look something like this:
In the snippet above, I’m using your terminal’s default colors (by using the named colors, like red , yellow or black ).

This allows tmux to play nicely with whatever color theme you have set for your terminal.

Some prefer to use a broader range of colors for their terminals and tmux color schemes.

If you don’t want to use your terminal default colors but instead want to define colors from a 256 colors range, you can use colour0 to colour256 instead of red , cyan , and so on when defining your colors in your tmux.conf .

Looking for a nice color scheme for your terminal?

If you’re looking for a nice color scheme for your terminal I recommend to check out my very own Root Loops .

With Root Loops you can easily design a personal, awesome-looking terminal color scheme and stand out from all the other folks using the same boring-ass color schemes everyone else is using.

You can find my complete tmux.conf (along with other configuration files I’m using on my systems) on my personal dotfiles repo on GitHub.

If you want to dive deeper into how you can customize tmux, the canonical source of truth is tmux’s man page (simply type man tmux to get there).

You should also take a look at the elaborate tmux wiki and see their Configuring tmux section if this blog post was too shallow for your needs.

Both will contain up-to-date information about each and every tiny thing you can tweak to make your tmux experience truly yours.

Have fun!

you can still invoke “go to beginning of line” by typing C-a C-a ↩

Source: This article was originally published by Hacker News

Read Full Original Article →

Share this article

Comments (0)

No comments yet. Be the first to comment!

Leave a Comment

Maximum 2000 characters