Open text files with TextWrangler, from the terminal (of-course Mac OSX)

You may choose one of the three approaches below.

As a one-time thing

open -a TextWrangler.app myfile.txt
open -b com.barebones.textwrangler myfile.txt # same thing by ID

To make TextWrangler the default:

  1. “Get Info” on a text file in the Finder.
  2. Change the “Open with:” program to TextWrangler, in the fifth information pane.
  3. Click the “Change All…” button at the bottom of the pane.
open myfile.txt

Install command-line tools

If you installed the MacApp store version, download the installer from http://www.barebones.com/store/macappstore.html and install.

If you downloaded from the BareBones Software site, there should be an “install command line tools” command in either the Application (TextWrangler) menu or the help menu. I think it’s in the Text Wrangler menu.

Once you have the TextWrangler command line tools installed, you can just type

edit my_text_file.txt

in the terminal and it should open.

Create a shell alias

This approach is also good if you don’t want to change your default editors.

$ alias tw='open -a /Applications/TextWrangler.app'
$ tw myfile.txt

To have the alias available in every shell you open, just add the line to .bashrc in your home directory. If you don’t have a .bashrc yet, just create it yourself and add the line.

Good Luck.