Linux Commands

How Do I Change Colors in tmux

While learning to use the command terminal can make your life easier, managing all your commands and shell scripts in a single window can prove to be a hassle. Although Linux distributions allow you to open more than one terminal window on your system, they don’t provide you with additional features and customizability options.

This is where tmux comes in. tmux is a multiplexer for your terminal. It allows you to run and manage multiple terminal sessions on your device. tmux comes with a lot of shortcuts and features that make it one of the best alternatives to the default terminal on your Linux distributions.

Customizability in tmux

The features of tmux aren’t just limited to technical improvements. tmux also offers visual customizability options. Changing text, layout, and colors, on tmux is possible by making some changes in the configuration file.

That being said, you might find yourself lost in how you can improve your tmux experience by switching certain parts of the window to the colors of your choice.

This guide will help you learn how you can change colors in tmux. We’ll go over how you can change the color of pane windows and text, along with some other fun options.

Starting a tmux Session

First and foremost, start by initializing tmux. This can be achieved with the help of the Linux command terminal.

It should be noted that we’ll be using Ubuntu 20.04 LTS. However, the instructions are not that different for other Linux distributions.

To start a tmux session, start by opening the command terminal on your Linux distribution. The shortcut key is Ctrl + Alt + T.

Once done, type the following command in the terminal:

$ tmux

This should start a tmux session on your system. With tmux initialized, you can move on to the next step.

Customizing Panes in tmux

A pane refers to a split session that’s open in a single window. tmux allows you to open more than one pane in a single window. This can be done with the help of the following shortcuts:

  • To split the tmux window into two vertical panes, press Ctrl + B and type %
  • To split the tmux window into two horizontal panes, press Ctrl + B and type “

When cycling through different panes, you will notice that the border window is highlighted in a dark green color. You can change this to a color that’s easily viewable for you by following these steps:

Start by making sure that you’re in your default home directory. You can print the directory you’re in with the help of the following command:

$ pwd

This should print the directory you’re in. In case you’re not in the directory of choice, use the $cd command to change the directory as follows

$ cd <path>

Once that’s done open the tmux.conf file in a text editor. For this tutorial, we’ll be using nano.

$ sudo nano ~/.tmux.conf

This should open the tmux configuration file.

In the configuration file, you can change the pane border colors by adding the following:

  • set -g pane-border-fg <color name> Changes the border color of all panes
  • set -g pane-active-border-style fg=<color name> Changes the border color of the pane highlight

This should change the color of the tmux panes.

Changing Status Bar Styles

tmux can also be used to change the style of the status bar. Like the previous section, this also makes use of the tmux configuration file.

Follow these steps to change the status bar visuals on your system:

First, open the command terminal and start a tmux session. Once that’s done, navigate to the home directory and open the tmux configuration file using the following command:

$ sudo nano ~/.tmux.conf

Once the configuration file opens, add the following line to change the status bar colors:

$ set-option -g status-style bg=<color 1>, fg=<color 2>

This will change the colors of the status bar according to your preference.

Aside from this, you can customize the texts, style, and even the alignment of the starting command using tmux. You can read more about these changes in the official tmux documentation.

Conclusion

While changing colors may seem like a minor thing, it can make quite the difference in readability and make the overall experience better. This concludes our guide on how you can change colors in tmux. We went over the basics of tmux and how to initialize a session. Afterward, we talked about the tmux.conf file and how it can be used to make visual changes. These changes included changing the foreground color of pane borders along with border highlights. Lastly, we covered how to change the colors in the status window.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.