Pages

Sunday, February 23, 2014

Dev Tip of the week - OSX Spotlight search from terminal

This is a really cool tip that I came across that allows you to perform OSX Spotlight search from the Mac Terminal. Add following to your .bashrc or .zshrc on the Mac to do Spotlight-indexed searches from the command line.

function spotlight() {
 mdfind "kMDItemDisplayName == '$@'wc";
}

Example
 ~ spotlight main.py  
 [/Users/hakim] /Users/hakim/main.py