mailpipe

November 14, 2016

I like creating tiny productivity tools. I like the command line. I love how everything pipes into each other. I get joy from things that are slightly silly.

When investigating a bug or issue, there’s usually some querying and grep-ing, and then sending the results to someone. The first part pipes nicely, even into the clipboard, but then I still have to paste the results into a mail.

What I want to be able to do is this:

cat incident.log | grep 'some filtering' | ruslan 'I think I found it...'

Where “ruslan” is the name of a colleague.

My first thought was, there must be a “mail” command. Alas, No.
I googled “CLI mail client Windows”, but did not find anything sufficiently simple.

So the easiest way was to write a small program: mailpipe.exe
It takes 2 CLI parameters: to and subject
and puts standard input into the body.

Make a personal pipe:

alias mailpipe='~/tools/mailpipe.exe'
alias ruslan='mailpipe ruslan@ourcompany.com'

or a bunch of personal pipes:

declare -a usernames=("mathias" "ruslan" "tim" "vincent")
for username in "${usernames[@]}"
do
    alias "$username=mailpipe $username@ourcompany.com"
done

Tadaaah! Much to my delight, I can now pipe data into my colleagues.

Additionally

Since this tool is mine, I can recognize specific types of data that I tend to pipe into it and add formatting. This wouldn’t make sense in a general purpose tool, but in a personal tool, it only needs to fit my needs.

For example: if I pipe tab separated data into it, it will format it as a HTML table.

Joy!