#Name space your shell commands
From the awesome jim blandy
Create a directory to hold all your little project-specific scriptlets; mine is ~/moz/bin
.
Then, create a script in your personal bin directory --- my little script is called ~/bin/moz
--- that reads something like:
#!/usr/bin/env bash
PATH=$HOME/moz/bin:$PATH
exec "$@"
Then, you create your little utility scripts, like ~/moz/bin/clean-hg-unknowns:
#!/usr/bin/env bash
hg status -nu0 . | xargs -0 rm
Now, you can invoke that anywhere like this:
$ moz clean-hg-unknowns
Note that the "$@" is kind of a magic thing: it gets all the quoting, etc. exactly right --- the arguments your subcommand gets are exactly those that the 'moz' prefix got, just with the 'moz' dropped. It won't be confused by spaces, leading dashes, embedded quotes, and so on.