Apr 03, '02 09:16:01AM • Contributed by: porkchop_d_clown
The following two scripts correct this. In addition, they also support creating aliases for applications that aren't in the /Applications directory. The biggest benefit of using these scripts is that they will automatically detect whenever you install a new application, and rebuild the appropriate aliases file!
[Editor's note: I have installed these scripts, and they do exactly what they're supposed to do - they create command-line aliases to all your applications on the fly. Quite cool...]
To use these scripts, first find out if you have the personal Library folder called "Library/init/tcsh". If you do not, you should create it, either with the Finder or by using the command mkdir -p ~/Library/init/tcsh from the terminal.
Once you have done this, start up your favorite editor (vi, pico, BBedit, whatever) and create a file called "~/Library/init/tcsh/aliases.mine". It should contain the following text:
foreach f ( $ALIASDIR/* )If you already have an "aliases.mine" file, just append this new script to the end of the existing one.
source $f
end
Next, create a file called "~/Library/init/tcsh/rc.mine". It should contain the following text:
set OSXDIRLIST="/Applications /Developer/Applications /Users/YOUR_USERNAME/Applications"Be sure to change the value of OSXDIRLIST to point to the directories where you keep your applications. If you already have an rc.mine file, just append this script to the end of your current one. Now, save this file and launch a new terminal. You should see a message like this:
set ALIASDIR="~/.osxaliases"
if ( ! -e $ALIASDIR ) then
mkdir $ALIASDIR
endif
foreach dir ( $OSXDIRLIST )
set file=`echo $dir | sed -e 'y#/#_#'`
if ( -M $dir > -M $ALIASDIR/$file ) then
echo "Updating $dir aliases..."
find $dir -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 "\" \\\\!* &'\''";\
}' >> $ALIASDIR/$file
endif
end
Welcome to Darwin!Note: you will only see these messages the FIRST time you open a terminal after installing the script, or installing a new application. Don't expect to see them every time!
Updating /Applications aliases...
Updating /Developer/Applications aliases...
Updating /Users/mheinz/Applications aliases...
[ibook:~] user_name%
If you type the command "alias", you should get several pages of output. For example:
quartzdebug open -a "/Developer/Applications/Quartz Debug.app" !* &This is a small excerpt of the file, obviously. You should see an alias for each application in the OSXDIRLIST you specified in the rc.mine file.
quicktimeplayer open -a "/Applications/QuickTime Player.app" !* &
sampler open -a "/Developer/Applications/Sampler.app" !* &
