image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets


Files are in Stuffit 5 or greater format.
Free download.

Tell us about a bad link.

Thank You!


Running
without a restart.

Opening GUI Applications from the Command line. by Michael Askew

When Michael Askew first figured out that he could open GUI applications from the Mac OS X terminal, it seemed rather cumbersome to type in the path to the '.app'. To solve this he came up with this approach.

Save the following script as a file named '.getosxaliases' inside your home folder (/Users/yourname/), then open a terminal and type: set OSXAPPSDIR = /Applications

(Make sure to change "/Applications" above if you have your OS X applications stored in another place for some reason)

# The Script:
# Update the .osxaliases file if it's out-of-date
if ( -M $OSXAPPSDIR > -M ~/.osxaliases ) then
echo "Updating OS X aliases..."
find $OSXAPPSDIR -name '*.app' -prune -or -name '*.dock' -prune | awk\
'{\
count = split($0,path,/\/|\.app|\.dock/);\
name = path[count-1];\
name = tolower(name);\
gsub(/ |\(|\)/, "", name);\
print "alias", name, "'\''open -a \"" $0 "\" \\\\!* &'\''";\
}' > ~/.osxaliases
endif
source ~/.osxaliases

Next add the following line to the ".tcshrc" file in your home directory:

source ~/.getosxaliases

What this pile of gibberish does is provide you with a way of conveniently launching applications from the command line, provided they end in a ".app" or ".dock" extension. For instance to launch the application "Internet Explorer" you can type: > internetexplorer

or to launch Stickies just type: > stickies

You can even open a file with TextEdit: > textedit somefile.txt

The command name for an app will be the name in lowercase letters with no spaces and no '.app' or '.dock' extension. All other characters must be included, but remember you can hit tab to auto-complete long names.

Some limitations/caveats :

1. Only applications that have a '.app' or '.dock' extension will have shortcuts. (Netscape 6 and AIM are a few that don't.)

2. Since these are launched into the background the Terminal will print a line similar to the following the next time you enter a command. This just tells you that it's through with the job. To prevent this remove the '&' from the print statement in the script.

3. When you install new applications the new command will not be available in active Terminal windows. The next time you open a Terminal window you will see the line "Updating OS X aliases..." momentarily. When the prompt appears the new command will be available

4. Don't open two new Terminal windows in rapid succession if the first one begins to update the aliases.

5. Some application names may override existing Terminal commands. For instance, "Mail.app" will get assigned the command "mail" which is already the name of a command line application. To get mail it's regular meaning back, append the following to the end of the script: unalias mail.

Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]