Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Launch Terminal commands via Finder filenames' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Launch Terminal commands via Finder filenames
Authored by: vajonez on Feb 27, '03 02:24:03AM
Neat tip. To avoid having to to mess with "Get Info" and "Open With:" use the following command and save the file with a ".command" extension:
#!/bin/sh
exec $(echo ${0##*/} | tr ':' '/' | sed -e s/\.command$//)


[ Reply to This | # ]
More robust with | sed -e s/.command$//
Authored by: jzsimon on Mar 21, '03 11:58:44AM

This method is actually more robust. Firstly it doesn't require the .command extension but does allow it. Secondly, there are filenames which will not work without the .command extension, because the shell script file takes on the same extension as the last file in the filename, which can change the filetype as far as the OS is concerned.

As an example, try the file name "open /Applications/Preview.app.command". It works great with this more robust method. Then try the file name "open /Applications/Preview.app". This fails miserably because the OS interprets the file as an application, suppresses the .app extension, and then never lets you put it back.



[ Reply to This | # ]