This is starting to become a thing. When I need to relax, I end up playing with bash.

This time I set up a dynamic Message of the Day (motd). For the uninitiated, typically bash will print out the contents of a text file upon the creation of a new login session. In this case, I cleared out that file and added a couple lines to my bash_profile to run this script in its place.

I started off with something cha55son posted here and tweaked it to work on OS X and fit my needs.

Repeatedly calling top seemed pretty hamfisted, so I call it (and other commands) just once and save the output to a variable that I can read later on.

I rather liked the idea of shortening my bash prompt, so the warm welcome includes the current username.

Uptime and Load data took a bit of finagling. I am no awk expert and so things here could probably be cleaned up by someone who actually knows what they’re doing, but I just threw sed at the problem and got it working.

In keeping with the idea of shortening my bash prompt, I also included the system hostname in the motd. I already try not to leave sessions open, so now I should always know where and who I am without sacrificing those precious columns.