Commandline-Aliases for all Mac-Apps

I frequently have the problem that I want to open a particular file in a “GUI”-app from the commandline. This can be achieved using the open [-a ApplicationName] filename command, but typing this is annoying. Therefore I added some lines to my .profile:

# Go through the Mac-Applications and define command-line aliases
echo -n Creating aliases for Mac-Applications
for a in /Applications/*.app /Applications/*/*.app /Developer/Applications/*.app /Developer/Applications/*/*.app
a=`basename "$a"`
b=`echo "$a" | sed -e /\.app/s/// -e /\ /s///g`;
alias "$b"="open -a \"$a\"";
echo -n '.'
echo done.

So now, I can type e.g. TextEdit muff.txt, which is quite convenient.