Linux Commands

Customizing the Status Bar in tmux

“In tmux, the status bar is displayed at the bottom of the tmux window and shows relevant information to the user. This information, by default, tells the user about the currently active tmux session and provides date-time information of the system the tmux session is running on.”

Anatomy of the Status Bar in tmux

The status bar in tmux is divided into three parts, as shown in the screenshot below:

The middle part of the bar displays a list of windows in the currently active tmux session. Whereas the parts on either side of the bar are called status-left and status-right. These are the parts of the tmux status bar we are going to learn how to customize in this article.

How to Set Customization Options in tmux

There are many ways to set customization options in tmux, including through the use of a configuration file and the use of the Prefix +: option. In tmux, there are four types of options for customization: session, window, server, and pane options.

Each session has a set of session options which can be set through the command option in tmux. These options are set using set-option and can be displayed using show-option. If a particular option is not configured for a session, the session inherits this option value from the global session options.

To see global server options, show-option -s can be used in the command mode in tmux or the tmux terminal shell:

Similarly, global server options can be set using set-option -s in the command mode or in the tmux terminal shell.

Window and pane options work in a similar fashion to session and server options. For window options, a set command can be used with -w switch, or in short form, setw can be used as well. For example, if you want to change the separator icon in the status bar for windows, you can do so with the following command:

$ tmux setw window-status-operator “|

The result of this command is shown below:

To change a pane option in tmux, the set option is used with the -p switch. This switch is not optional, as not including it makes tmux default to changing window options. A newly created pane inherits all its options from the window it is a part of. Therefore, all pane options can be set as window options, which can then automatically apply to all the panes in the active window. If you want to change an option globally, you can do so by setting a window option with a global -g switch instead.

Unsetting an Option in tmux

To unset an option in tmux, -u switch used in conjunction with set option. For example, in the screenshot above, when you set the vertical bar as the window name separator, you can unset it using the following command:

$ tmux set -u window-status-separator

Moreover, it will revert the option to the global default window separator. For example, this is shown in the screenshot below:

Set Customization Options Using .tmux.conf File

By default, the configuration file that tmux reads and executes options from is located in the user’s home directory. To create this file, execute the following command on the terminal:

$ touch ~/.tmux.conf

Then you can edit this file in your favorite text editor to add or remove options for the status bar and control the behavior of tmux comprehensively. For example, if you want to turn off the status bar globally, you can write the following command in ~/.tmux.conf:

set status off

Setting Customization Options Using tmux Command Mode

Similarly, you can use this command from within tmux as well by hitting Prefix +: and typing set status off in the command mode. This is shown in the screenshot below:

As you can see, the status bar for tmux has been turned off. However, it can be brought back by using set status on command in the command mode.

Setting Customization Options Using Shell Within tmux

A third way to achieve the same is by using the shell’s tmux command to set or unset options. Running the following command will turn off the status bar in tmux:

$ tmux set status off

The result is shown in the screenshot below:

Reloading tmux Config File

These three methods of setting options for tmux produce very similar results. After editing the config file, it has to be reloaded in tmux, which can be done with the following command:

$ tmux source-file ~/.tmux.conf

Or using the command mode as follows:

Prefix + :
source ~/.tmux.conf

Moving Window List in tmux Status Bar

By default, the tmux status bar shows the list of windows in the currently active tmux session on the left side, adjacent to the status-left option. You can change this behavior through the status-justify option, as shown in the screenshot:

The -g switch provided to the set option in this command is used to modify behavior globally.

Changing Colors in tmux Status Bar

To change the colors in the tmux status bar, you can use the set-option command with the desired colors. For example, if you want to change the foreground color to white and the background color to white, you can use the following command:

$ tmux set-option status-style fg=white,bg=black

The effect of this command on the tmux status bar is shown below:

Colors supported in tmux by name are: black, red, blue, green, white, yellow, magenta, cyan

Also, bright colors are supported as well, such as brightgreen, brightred, brightblue, etc.

256 color set is supported, ranging from colour0 to colour255.

Hexadecimal color codes are supported as well, similar to how color codes work in HTML documents.

Changing the Display Style of Clock in tmux

In tmux, there is a clock mode that can be entered by using tmux clock-mode or Prefix + t by default. This is what the default clock mode looks like in Ubuntu 22.04 installation:

However, this clock can be styled as well, using shell command or command mode in tmux. In order to change the clock in the above screenshot to be white, the following command can be used:

$ tmux set-option -g clock-mode-colour white

This command changes the clock face display globally, as the -g switch is used with it. Any windows or panes which are in clock mode in tmux are therefore affected by this. As a result of this command, the clock face display changes to white in clock mode, as shown in the following screenshot:

Conclusion

There is a wide range of customization options available in tmux for users to change the behavior of their status bar. This includes changing how the status bar displays information as well as what colors are used to display such information.

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.