URL Highlighter for ZSH

url-highlighting-terminal

A long time ago, on a computer far away from here, I copied and pasted the pattern highlighter from the excellent zsh-syntax-highlighting project and stuffed in a bunch of crappy code so that it would check whether or not a URL was responding with 200 OK.

It was slow, it was buggy, and I never got around to doing anything with it.

Fast-forward 3 or 4 years, a couple of issues on the tracker, and I get a code review.

“What? Someone is code reviewing that piece of junk?”

Yes, they were. And it turns out that my little highlighter was getting many more clones than I expected and was listed on an ‘awesome list’ for zsh plugins.

Ah.

I felt terrible.

All these people who were probably excited at the prospect of highlighting URLs in their command lines, having their dreams shattered by my inability to write zsh code with anything approaching competence.

I needed to fix it. I jumped onto #zsh and #zsh-syntax-highlighting, nagged everyone, asked too many stupid questions and learnt tons. I decided to stop using oh-my-zsh and ‘hand-craft’ my own zsh configs from scratch. It has taken me the best part of too-many-days, but I have a much better understanding of how zsh works and how to manipulate it than I did when I first pushed this highlighter out of my Incompetence and into the Big Wide Internet World.

So, I’ve rewritten it from scratch. It highlights multiple URLs on the same line. It does some basic caching so that it doesn’t request the URLs you type four hundred and seventy million times per keystroke. It even has some configuration options (wow!).

So go ahead, try it out: https://github.com/ascii-soup/zsh-url-highlighter

If you’ve tried it before and been burned by the fact that I’m as incapable as I am annoying, then I’m sorry. Give it another go?