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


Click here to return to the 'Automatically create app-launching aliases in bash' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically create app-launching aliases in bash
Authored by: vtron on Jul 13, '06 04:48:23AM
There are potential problems with careless aliasing like this.
For instance running the script with changing the relevant awk line changed to
printf "%sn",name
and then
for name in ~/.osxaliases `; do which $name ;done
reveals then various aliases would redefine existing executables in the path.
Some of these are actually the same application (automator) but not necessarily (/usr/bin/mail is not the same as /Applications/Mail.app)
On top of this, even pure Apple applications may exist as duplicates or just found in volatile source building directories.

I suggest that your script does the update in two stages checking potential aliases with `which` after the first stage and does not redefine already existing ones while warning the user.

So I suggest writing
printf "%st%sn",name,appl;
to $ALIASFILE (change the relevant line in .profile) and then instead of just sourcing $ALIASFILE in .bashrc, do

cat $ALIASFILE| while read name appl ; do if which $name; then echo $name exists; else alias $name="open -a '$appl'" ;fi; done

Plus, we might want to check if the required aliases already exist as aliases but I'm not sure how to do that other than grepping it from the output of alias. with this duplicates coming from different Application directories could also be detected.

For another problem technical see the next post.
V

[ Reply to This | # ]