Skip to content

Instantly share code, notes, and snippets.

@algal
Last active November 12, 2020 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save algal/a2f3ec7c0f05a3457567d0af560e9528 to your computer and use it in GitHub Desktop.
Save algal/a2f3ec7c0f05a3457567d0af560e9528 to your computer and use it in GitHub Desktop.
Easily search for files based their names or glob patterns, by wrapping Spotlight.
#!/usr/bin/env bash
# case-insensitive search for $1, maybe in dir $2
case "$#" in
0) echo "usage: $(basename $0) PATTERN [DIR]"
echo ""
echo " Lists paths of files matching PATTERN in DIR or below"
;;
1) exec mdfind "kMDItemDisplayName == '$1'c"
;;
*) exec mdfind "kMDItemDisplayName == '$1'c" -onlyin "$2"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment