Chock amok

During this calm before the upcoming Apple storm, we should all take time to read and contemplate the 30+ years of command line wisdom summarized in this recent post by Craig Hockenberry. I started using some of his tips right away; others will have to marinate for a while until I’m ready to chew on them.

Craig’s tips cover a broad range of topics and include discussion of

So far, my favorite tip has been the addition of these two lines to my .bashrc file to search backward and forward through my command history using the up and down arrow keys:

bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'

Bash normally uses ↑ and ↓ to move backward and forward in the command history one command at a time. But if you have the beginning of a command typed, these bindings cause ↑ and ↓ to move back and forth through only those commands that start the same way. Very clever and very useful. For years, I’ve been using ⌃R and ⌃S to search backward and forward through the command history, but this is much simpler.

The section of Craig’s post I need to study further covers the md* commands that leverage Spotlight and the metadata it uses. I’ve used mdls to get the duration of audio files, but there’s so much more I could do with it and mdfind.

I think the best way to thank Craig is to write up our own tips. Here are a couple of mine:

I look forward to seeing Terminal tricks from all of you.


  1. For reasons lost in time, don’t have a .profile file. I keep my bash settings in .bashrc and have a .bash_profile file that sources it. Something to do with login and non-login shells, as I recall.