Over the past few weeks I have been working on tweaking a bunch of configuration files (aka “dot files”) for programs I regularly use, primarily those used on the command line, and I now have things working really well. Part of the reason for this recent effort is my switch from the bash shell to zsh. I don’t want to get too much into the “why” of that, but the main driver for that change was improved completions and other fancy features. I found a couple of really neat tricks to improve the usability of zsh. One was syntax highlighting while typing commands, another was toggling the cursor colour to red when in vicmd mode. While both are really neat tricks, I just cannot get things to work with my setup 100%.

For the syntax highlighting, I found that on at least one of my computers, enabling the “root” highlighter would cause every key stroke to emit an annoying beep while acting as a normal user, and then just wouldn’t work when root. The highlighter basically just inverts all colours to emphazise that you are in a special mode, which is nice, but I can live without, so for the time being I have just disabled it.

The vicmd cursor colour trick is a little more frustrating. I really like the extra feedback it gives to the user. It even works for me most of the time. The problem I’m having is that when I have it enabled and I am using tmux (a terminal multiplexer, similar to screen) and I am using all that inside gnome-terminal, I occasionally get a beeping sound and an escape code 112 gets printed to the screen. This code is emitted by tmux when it wants to reset the cursor colour to default, usually performed when the tmux status bar updates. Unfortunately, gnome-terminal doesn’t know what to do with this escape code, so it just prints it to the screen and beeps at you. One person online said that gnome-terminal does this on purpose to emulate xterm, but when I tried this in xterm, everything worked as expected. I tried for a little while to get xterm to do all the things I was used to having in gnome-terminal (URL detection, copy/paste without using the mouse buffer, paused tty scrolling, proper unicode display, decent font, etc.) but that was just more of a headache.

For now, I’m just disabling the vicmd cursor highlighting when I’m using tmux. I had been planning to switch from using gnome-terminal tabs to using tmux locally (right now I’m just using tmux on my remote connections). If I do make that switch, I’ll basically lose the vicmd colouring completely. What I need to do is find a way to get tmux to suppress the 112 escape code, get gnome-terminal to just ignore the code, find a less frustrating way to move away from gnome-terminal, or at the very least detect that I am both within a tmux session and gnome-terminal (which might not even work when reconnecting to a tmux session). I’ve been fiddling with this for a few days now and can’t seem to get a proper solution and just felt like ranting about it. If anyone has any suggestions for fixing this problem, I’m all ears.

No Comment.

Add Your Comment