How to run bash_profile function from desktop alias .command file on OSX Lion?

Solution 1:

I don't know why functions aren't available here, even though ~/.bash_profile is sourced. You can test this by putting another command into your .bash_profile, and seeing it executed when you run the .command file.


If all you really want is to have a double-clickable item that launches this function, open up Automator.app from Applications/Utilities, and create a new Application.

Drag Run AppleScript from the left pane, and paste the AppleScript command.

Save it as a file, e.g. Open Firefox.app, wherever you want.

Of course, you can also use Run Shell Script instead of Run AppleScript if you need just plain shell script commands.