TextWrangler is my favorite editor on my Mac. There are times when I want to run it from the Terminal by passing it a file name. I wanted it have a short name as well. Like this tw <file name>, much like vi <file name>. This can be really useful when I need to invoke it from scripts.
First I tried to use the alias command to create a short cut. But alias cannot accept command line parameters. So if I were to type tw Gemfile, TextWrangler would open empty, and Gemfile would open in TextEdit. So I created a function in .profile called tw like this.
function tw() { open -a /Applications/TextWrangler.app "$@" ; }
(the -a is how text wrangler knows that it needs to read the arguments, and the $@ is how the arguments get to the function. Now tw Gemfile works like a charm.


Recent Comments