Apple - Can I open files in TextEdit from the Terminal in Mac OS X?

open -a TextEdit filename should do the trick.

The -a flag specifies any application you want, so it's applicable to any number of situations, including ones where TextEdit isn't the default editor.

Other relevant options

  • -t opens in the default editor (i.e. if you use BBEdit, TextMate, etc.)
  • -e will open the file specifically in TextEdit

Direct, easy answer - add an alias to your ~/.bash_profile like:

alias textedit='open -a TextEdit'

Invoke it like:

textedit theFiletoEdit.txt

The difference between this and the other answer, is you can easily remember it when you want it. Typing text and Tab to autocomplete it will make it instantly available


For those with a bit more bash background, who want the reasoning without having to fuss with figuring it out:

  • The problem is that a trivial symlink (or its ilk, like a shell script redirect) to /Applications/TextEdit.app/Contents/MacOS/TextEdit causes a new instance of TextEdit to open the file you pass to it. This works, but does not give your expected Mac OS X default behavior. (if you try it, you'll see)

  • To get the default UI behavior, using the Mac built-in open command, with that '-a TextEdit' flag (that others mentioned) induces the Mac UI to have (any) currently running instance of TextEdit handle the call (with no inapropos 'sudo' needed for general case usage).


The open command can be used to open files (in their default apps, unless using the -a flag), URLs (in your default web browser), and directories (in Finder).

An example would be

open /Users/Example/Desktop/example.rtf