Custom iTerm2 titlebar background colors
Make your iTerm2 setup look as beautiful as Hyper. iTerm2 supports proprietary escape codes to achieve just that. Read the story to find out how they work.
If you are like me, you get pretty obsessed about the look and feel of your development environment. It’s such a productivity waste, but I am a sucker for nice looking apps. After all, as a dev, you look at this stuff all day.
Sadly, though, I cannot get myself to use these apps for work. I am used to Neovim/Vim and Atom’s model for splits is way too different. It just does not feel right. And while Hyper is beautiful and its plugin system rocks, as soon as I try to run Vim in it, I start noticing all kinds of performance related glitches and lag. On top of all of that, these Electron apps just take too much of my system’s resources. Today, I noticed Atom causing 150% CPU load when I was scrolling its settings screen. Scrolling. Both apps regularly take up gigabytes of memory.
So, I am stuck with my iTerm2, tmux, Neovim combo, which is not easy to get to look really nice. With enough patience and determination, I think I ended up with a nicely looking setup (getting theme colors to work has become a lot easier thanks to True Color support across the stack). You be the judge.
However, one thing that always bothered me was iTerm’s grey titlebar. In the nightly builds, George Nachman has added support for macOS’ dark mode for the titlebar. This is nice, but still does not look as beautiful as Hyper.
Recently, I finally — by accident — found a solution to this problem. 🎉 Turns out, iTerm2 supports some proprietary escape codes for overwriting certain settings. And yes, there are codes to change the titlebar background color!
Here is how to set the titlebar color to the background of the iTerm2 One Dark theme I am using. Type the following into your iTerm2 terminal.
$ echo -e "\033]6;1;bg;red;brightness;40\a" $ echo -e "\033]6;1;bg;green;brightness;44\a" $ echo -e "\033]6;1;bg;blue;brightness;52\a"
This is what it looks like.
Finally. iTerm will not save this to your settings. The solution is to automatically execute the above commands when launching a new session. Just add them to your .bashrc or .zshrc, etc.