A Couple of zbell.zsh Bug Fixes

| Comments

I’ve been using zbell for over a month now, and I’m really starting to rely on it. Old habits are hard to break. I still find myself peeking at long running processes just to see if they’ve finished, but I’m slowly learning to trust that zbell will let me know when something needs my attention.

A test zbell.zsh notification

Deploying a new blog post using my laptop takes over thirty seconds. I always like to take a look at the live website after it publishes to make sure I didn’t goof anything up. I’ve finally stopped flipping back to the terminal window to check on the progress. Instead, I’m trusting zbell to let me know when it is time to check the blog.

One very, very annoying bug

Some people complained when I chose control-u as the default key for zsh-dwim. Control-u is bound to the function unix-line-discard by default. I’ve never used this function in my entire life. A key sequence that I use for a similar purpose all the time, control-c, has always been my preferred way of canceling a command that I am writing. It has the advantage of leaving the unfinished command on my screen, and that comes in handy if I need to reference my thoughts later on.

This action triggered a very annoying bug in zbell. Hitting control-c would cause zbell to immediately notify me of the previous command. This was very loud and quite annoying. This bug could also be triggered if you hit Enter on a blank line.

Thankfully, this was easy enough to fix.

A much less intrusive bug

The email notification in zbell also had a small bug. I had decided to include the command’s exit status in the body of the email, but I wasn’t squirreling that status away early enough. When you want to capture the exit status of a command, you have to capture it immediately. If you execute any other command before making a copy of the exit status variable, you will end up overwriting it.

This one was easy enough to fix, but it might still be pretty fragile. I added a line to copy the exit status to another variable right at the very beginning of the precmd hook, but any other functions bound to the precmd hook could mess that up.

I don’t have any other hooks, so this fix is good enough for me.

You can find the zbell.zsh Gist at Github.