I want to add an option to the finder context menu that calls hg add %1 with %1 being the full path of the selected file in finder.
Of course there are more
The steps have changed for Snow Leopard/10.6+ since @khachik's correct answer. To make sure its clear, here are the steps:
Servicefiles or folders in Finder.app"as argumentsYour Automator window should look like the this:
:
You can now select multiple files in Finder and then execute your service from the Services sub-menu.
For your script, I think you want the following. This changes to each argument's directory then adds it. I'm using a for loop because Finder allows you to select multiple files in different folders (which could be in different repositories).
for f in "$@"
do
cd $(dirname $f); hg add $f
done
If you assumed they are all in the same repository you could do this:
cd $(dirname $1); hg add $@