Marking Kitty Terminal Windows

We have probably all been there a few times - we have multiple terminal windows open, possibly containing production and development environments, and somewhere along the way we get mixed up and begin editing the wrong content. In these cases it would be helpful to have a way to "mark" windows in some way to make it more obvious which windows should (and should not) be edited.

Luckily, Kitty terminal's remote control feature provides a simple but effective solution.

First, follow the remote control tutorial to get an overview of remote control and learn how to enable this feature in your terminal, then follow along to see our solution.

Setting colors

Setting terminal window colors with Kitty's remote control feature is easy, simply navigate to the window that you would like to mark and type:

kitten @ set-colors background=red

With that simple command, we now have a big, obvious warning sign that this is not a window that we want to edit. You can of course pick any color that you would like to use, and Kitty understands both css color names as well as RGB hex:

kitten @ set-colors background=#00ff00

Although changing the background color is perhaps the most obvious way to mark a window, Kitty provides control over a variety of window formatting parameters. Here are some of the more interesting ones:

background=red

As we have seen already, this changes the background color of the current window, and is probably the most visible parameter to configure.

foreground=#ff8888

Changing the foreground (text) color can also be an effective method of identifying windows.

active_border_color=red

Setting the active border color provides a nice effect in which the coloring doesn't appear when the window is inactive, but becomes obvious when the "marked" window is activated.

cursor=red

For a more subtle effect, setting the cursor color might provide sufficient visual indication for some users, and this effect can also be combined with the active_border_color to enhance it.

Resetting Colors

The window colors via the command line persist until the window is closed, but if you would like to remove the color you can do so using the following command:

kitten @ set-colors --reset

Which resets window colors back to the original values set in your configuration.

Keymaps

Although these commands are easy to remember, Kitty provides additional functionality that can make this even easier to use - we can also map these commands to keybindings so that we can quickly toggle window colors. For example, here is a minimal configuration file that enables remote control and binds our commands to set and reset window colors to the f1 and f2 keys, respectively.

allow_remote_control yes
·
map f1 remote_control set-colors background=red
map f2 remote_control set-colors --reset

With simple modifications to this configuration, any window formatting that is used to mark windows can be easily enabled and disable using simple key bindings.