Shell Scripting

So since most of the shell scripts I write don't really deserve an entire post dedicated to them, I've decided to write one post detailing the Interesting scripts I have written (and my love for shell scripting!). Most of these helper scripts can be found in my bin.

Although I do love POSIX, admittedly not all of my scripts are POSIX compliant, the main reason for this is I really enjoy some of the features bash offers, such as

Just to name a few!

Other than what is used above, my scripts are POSIX compliant, hence if I want to ensure I write a POSIX script I basically just have to avoid using the above. With that being said I have rarely actually needed to write a POSIX script as I don't really need the portability it offers, and hence have relished in the sins of using these bash features.

Note, new scripts get added as they are made.

Now lets get into the scripts!


This simple utility, humbly named pdf aims to solve all problems I faced with when dealing with pdf's. Namely compiling, reading, etc! roughly speaking depending on the type of file given as the last argument to pdf dictates what we are doing. Below are examples.

$ pdf document.pdf # Open document.pdf in mupdf with a custom dark filter

$ pdf document.tex # Compile the LaTeX document to document.pdf

$ pdf man.1 # Compile the man page to man.pdf

$ pdf # Compile the markdown document to document.pdf

$ pdf -t > document.tex # Setup the skeleton format of a LaTeX documet


This little utility of mine makes listening/watching to videos/livestreams (either from disk or the internet) easier, and comes with another utility stream-helper which makes controlling a stream instance easier. The basic use of stream is something like:

$ stream -fva # Launch stream without video and select video from dmenu

We can then do something like below to pause the current video/audio

$ echo pp | stream-helper -t

This allows stream to be controlled through other scripts/ programs through the use of stream-helper, example pausing stream with a bind in dwm would simply be something like:

static Key keys[] = {
{ MODKEY, XK_p, spawn, SHCMD("echo pp | stream-helper -t")},

Then when pressing mod + p, we pause the current stream session.


Lets not forget the client for the noted project! This little script has undergone a few refactors, mainly just focusing on tidying up the functions etc. noted essentially interacts with the API provided by the noted server (aka noted-folder) to upload encrypted (planned to be at least) todo notes, as well as sync them.

Features include

  • Syncing notes between clients and server
  • (Planned) client side encryption using PGP
  • GUI and TUI modes


Although pm is technically some form of wrapper script, since 90% of the arguments passed to hit are simply passed to pass. The part where it is not a wrapper script is when we call

$ pm backup

As this is the feature I injected into my password manager, as I felt there wasnt really a sensible way to backup my passwords to other machines (either on my machines on my local network, or machines on a different network) that was still secure.

Then I it hit me, the most sane way to do this was to simply reuse the features of pass, but with a combination of ssh. Since ssh provides a secure channel I could simply decrypt my passwords and pass them through ssh to the machine I am backing up too, and then that machine sticks the password into pass again. Hence the backup feature was born!

The actual function which handles the backups is simple and is only ~42 SLOC, it can be found here, particular attention should be paid to how I handle the transferring of the passwords (found here), as I transfer all passwords in a single ssh session, which is as optimal as I had hoped for.

If you are interested, pm is fully described in its README, and it is recommended you read if you plan on using pm.


Grep implemented (kinda) in bash with a combination of lex and gcc. Is it stupid, yes. But don't stop here, go read the README.


Originally starting out as a telegram bot for my server (, it is slowly but surely becoming my personal assistant bot (once I implement my plans for it)

In its current iteration it simply warns me of when my server is down (and or sub services are down), alerting me that something is happening and I should investigate.