Housekeeping

2026: hk (repo) is my CLI tool belt for fixing everyday annoyances. Since I last wrote about it back in 2019, I had the opportunity to refactor it recently (from a bunch of shell scripts + Makefile) into a single binary. The tool is re-written in Rust, and it is fast, eliminating few options and dependencies I could get rid of. The repo. now has binary releases for a few OSes I use routinely.


My current work involves a lot of reading, and I receive a ton of files from many sources — colleagues, contractors, vendors, document systems, et al. The fact that I have instead tried listening to them in dull monotone (via text to speech) must be a giveaway. Last Sunday, I sat down to list all the minor house-keeping annoyances that stop me in my tracks while working, so I could do something about them. Here are the top five:

  1. Split and scattered pdf files in a folder
  2. Empty folders
  3. File and folder permissions
  4. Scattered LaTeX compile files
  5. pdf file sizes

I realised that I had solved these problems at one time or the other in the past, but hadn’t joined them up into a single tool belt that I could access with a simple command in one stroke. I realised I could create a Makefile that could make it all possible.

My hkp repository is a result of that. The tool-belt is now accessible from any folder at my finger tips. Here are the available tools:

$ hk
usage: make --file=~/scripts/hkp/hkp.make <cmd>
<cmd> available:
 cmbi   combine all pdf files in the curr folder
 cmbs   combine sub-folder-wise pdf files
 cmpr   compress all pdf files in the curr folder
 cr     delete and recreate master git repository
 efd    purge empty folders
 ffp    apply permissions: folders (755), files (644)
 help   show this help
 m2t    convert all markdown files to text in the folder
 plcf   purge LaTeX compile files
 sffn   sanitise folder and filenames

Among the above, combining files proved troublesome, especially with all kinds of poorly named files. For a while I tried rename, which proved to be dangerous. After a bit of research, I found detox, which does a great job of renaming bad names into sane, parsable ones that the script can handle. While it was easier to install on the Mac via Homebrew (brew) and via Advanced Package Tool (apt) on debian, a Cygwin version proved elusive. In the end, I compiled source (on Cygwin!) to get a working binary in /usr/local/bin. detox’s kung fu is a thing to admire. When you’re not writing regular expressions — to catch a bunch of poorly named files and failing often, it feels like magic.

New CLI tools

I’ve been discovering new tools, written by Rust programmers, with dramatic improvements in utility and speed.

  1. bat: A cat(1) clone with wings
  2. exa: A modern version of ls
  3. fd: A simple, fast and user-friendly alternative to find
  4. fzf: A command-line fuzzy finder
  5. rg: A fast alternative to grep
  6. rga: Search in PDFs, E-Books, Office documents, zip, tar.gz, etc.

The combination of ripgrep (rg) with fzf in live-searching (via) through my files cannot beat anything in Mac or Windows. Happy days!

rg --files | fzf