URL Highlighter for ZSH


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.


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?


KDE Plasma – Kickoff menu freezes when making adjustments

So I installed a fresh Kubuntu 15.04 on my desktop and all was going smoothly (ish).

I noticed that whenever I tried to move a program in my favourites list or add a new one, the whole Kickoff menu, the panels, everything just froze.

I found a fix.

There was a lock file, ~/.config/kickoffrc.lock that hadn’t been removed (I guess during some other edit I made) – I simply deleted this file and everything started working again.

Hope it helps someone else who has this problem!

oh-my-zsh git plugin tip

Just a handy little tip.

The zsh git plugin offers a handy little function called ‘current_branch’. This will return the current git branch in the current git repository.

You can call zsh functions within commands by wrapping them with ‘$()’.

This helps me to reduce one of the little frustrations I have with git – specifying the branch name when pushing.

Now, I can just type this:

$ git push origin $(current_branch)

Of course, I’ve shortened this by creating an alias for current_branch called ‘cb’, so I just type:

$ git push origin $(cb)

The alias can be added to your .zshrc with the following code:

alias cb="current_branch"

Simple and helpful.

recent-branches – a quick git command

I’m often switching between the same few branches in git – whether I’ve been distracted by doing a quick fix in another branch, or am doing a code review on a colleague’s branch – and get frustrated with having to type out the name of said branches all the time.

With that in mind, I created a quick ruby script that will show me my most recently checked-out branches (up to a limit of my choosing) and allow me to check one out quickly by typing a number.

As mentioned, the limit can be set by the user, simply by adding the key ‘recent.limit’ to the git config (either –global or in the current project) with an appropriate number.

If this sounds useful, grab the code here: https://github.com/ascii-soup/git-recent-branches

Static Rows widget for jQuery Tablesorter

I was using the fantastic jQuery Tablesorter plugin at work the other day and needed to keep a single “actions” row at the bottom of the table. I found the “Widget” tutorial and quickly knocked up a new widget that ensured my actions row stayed at the bottom when the columns were sorted, and then added the tidy-up job to my todo list.

So here it is. I tidied up the widget I created and allowed any rows to be marked as “static” by simply adding the “static” class to the <tr> tag.

Hopefully this will be of use to someone out there, as I found nothing while searching for something similar last week.

If you do use this widget, please let me know how you got on and if you find any bugs, please report them!

Download from GitHub

Not everything has to be a website!

Being a web developer, and working for a web development company, I often find myself coming up with ideas for new in-house tools that can improve our day-to-day lives.

Where I work, we have “creative days” once a month where us devs get to spend the whole day doodling around, playing with new technologies, building tools and generally just flexing our grey matter and keeping our skillset sharp.

Being a web developer, and working for a web development company, I often find myself building these tools as websites. It stands to reason; I use the LAMP[hp] stack all day, I live and breathe web and web technologies. Lately, however, I’ve been fiddling with C# and building *gasp* … desktop apps.

Continue reading