Building a basic command palette for Bash

I’ve been using tmux for a while at work, and in particular nested tmux sessions, one for each server I use regularly handled via a main session on a jump host. There are around 20 different servers I connect to for various tasks and navigating between them all via standard methods was a little tricky. I thought of the idea (which, of course, wasn’t a new thought) of having a fuzzy find so to get to box4, I could type x4<Enter>.

I had a look for anything that existed already and found marker and fzf which seemed really promising. Unfortunately, the servers I’m using didn’t meet the requirements so I wondered how tricky making something like this would be.

Continue reading “Building a basic command palette for Bash”

bash-todo: A TODO list in your terminal window

I recently saw this question posted in /r/bash and thought “that’s something I’d also use”. After seeing /u/whetu‘s comment and thinking about it, I realised it should be fairly easy to build a script that does exactly what’s required.

After a bit of tinkering and adding some basic styles I wrapped it up into a small Bash/Perl script (a polyglot, just for fun…) and placed it on GitHub. I’ve added a few basic switches to toggle/delete items, or slurp items from STDIN.

As part of this I also repurposed parts of my bash-ps1 tool so that you can easily create style strings including the colours and styling to help make your TODO list look just the way you want it. It’s available here and the source code is also on GitHub.

JavaScript shithead game

I’d started work on this some time ago, but hadn’t gotten around to fixing a couple of bugs. I finally did today!

It’s the variant that I used to play a lot when I younger (and still do occasionally) so follows those rules, but I’ve tried to build it in a way that it should be possible to modify the game to meet your rules. I quite like the Deck and Card object prototypes and I’m hoping to re-use them in another card game I’m toying with making a clone of.

I’m quite happy with the card styling too, I like the effect of the card stack and, despite the bug when you hover over the right-hand edge of the last card in a hand, I’m happy with how it functions!

You can check it out here, and the source code is on github for your forking pleasure!

Flow Free JavaScript clone

I’ve been playing a lot of Flow Free on my phone and tablet. Probably far too much, but I really enjoy it.

The aim of the game is to link each of the dots together with their counterparts via a drawn line, but you also need to ensure the whole box is filled with the lines. This means that on some levels there are multiple solutions, or that the solution you need is not obvious!

I was interested in how easy it would be to re-make the game in web technologies, so I took the opportunity to learn about CSS variables and experimented with very minimal HTML.

The result is available to experiment with on Codepen and the source is also available on github.


Seems I’ve been all about the terminal customisation recently…

I use grep a lot. Multiple times every day without fail. I used ack for a while when I started at my current workplace as that seemed to be favoured by a lot of the existing devs there. However, I found that not having ack on some servers meant I was making silly mistakes when using grep elsewhere. Ever typed this:

grep -R 'variable'

and sat there waiting? Well I have. So I switched away from ack and became a grep advocate. This move from ack might also help explain my grep default flags, one of which (that I didn’t mention in that post..) is -P to use perlre in the search string.

Continue readingGREP_COLORS tool” pages

I’ve been sharing my code via github a lot more lately. I’ve used Google Code in the past and haven’t really used github extensively. Using it more and more now has made me feel I should share my tools via, not a lot of people want to go to links on someone elses blog in case they’re using it to gain money via ads or something. I don’t use advertising, I can’t stand ads in general and block them in any way I can, so you don’t need to worry about that here!

Anyway, I’ve added my recent tools and script to a page which is accessible here:

I’ll continue to publish articles here as well, and would like to use this as a way to get feedback and elaborate on any interesting parts of the code I’ve written. As well as write more rambles if and when I feel the need!


terminal-preview is a collection of JavaScript and CSS that will enable parsing and styling of terminal ANSI escape codes for simple preview. It’s been developed as a result of my experimenting with bash-ps1 and image-to-ansi.

I’d wanted to extract the code I used in the those projects into a stand-alone project/component that could be added to an existing page where ANSI escape sequences need to be interpreted. I’ve toyed with the idea of making it a Web Component or something like that but haven’t just yet.

Continue reading “terminal-preview”

Learning Perl through code golf

Before I started with my current employer almost six years ago I moved from a small, privately-owned, web development company with a few developers working in the languages we chose (or at least, could make a good enough argument for) and with tools recommended by each other or the latest and greatest libraries we’d recently discovered. This was great fun and whilst we dabbled in other languages, learning Ruby and Python, tinkering with shell scripts and Haskell, there were things we didn’t touch because we didn’t have to. That was, until another developer that was no longer with us, created a Perl script that needed updating. The fear in our eyes when that script came up, or when it needed to be used again for another client…

Continue reading “Learning Perl through code golf”

Poor man’s __git_ps1

Recently one of the remotely maintained servers I worked on regularly has started to exhibit slowdowns in bash. It started only occasionally, perhaps as a result of a high number of users or long-running script, but become a lot worse and resulted in a few seconds delay every time a new prompt was drawn. A few seconds may not sound a lot, but can be incredibly frustrating!

Upon a bit of an investigation I found that the culprit was the call to __git_ps1 in my $PS1 variable. Removing this made the bash prompt speedy again! Hooray! However, having the current branch on my screen immediately is infinitely useful and I can’t really live without it any more, so I carried on digging.

On this particular set of servers git has been replaced with a set of custom script that perform a lot of tasks. This means that calls to simple git commands run a LOT of other commands, logging and getting repo information among other things. I thought about replacing all the references to git in the file with the direct path to the binary, but thought it shouldn’t be too tough to just get the information myself using the information in the .git folder.

The result is this bash function.

It’s fairly primitive, it checks the current path for a .git directory, if it doesn’t find one, it goes up one level, until either finding one, or hitting the root. It printfs the result in the same way as the real __git_ps1 and handles the basic states like |MERGING although doesn’t detect a detached HEAD any other similar states, but serve the main purpose, now I can correctly see my current branch and avoid committing the wrong thing to the wrong place!

Feel free to share if this is useful and let me know if there are any minor improvements (short of using the full version!).