Text Editors For Mac Terminal

  1. Best Free Text Editors For Mac
  2. Text Editors For Mac Terminal Commands
  3. Free Text Editors For Mac
  4. Text Edit In Terminal

I liked and appreciate the “Using the Text Editors Hidden in Terminal” post. I rarely use emacs and the terminal window in general. But, when I do, I can do things that are difficult or impossible in MicroSoft office, to my knowledge.

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.). The Best Free Text Editors for Windows, Linux, and Mac Lori Kaufman April 28, 2012, 12:00pm EDT We all use text editors to take notes, save web addresses, write code, as well as other uses.

Active3 years ago

I frequently find that a Terminal command to open a file in TextEdit would be very handy. Does such a command exist on Mac OS X?

Allan

Best Free Text Editors For Mac

47.8k16 gold badges78 silver badges187 bronze badges
wfbarksdalewfbarksdale

migrated from stackoverflow.comSep 23 '11 at 23:53

This question came from our site for professional and enthusiast programmers.

5 Answers

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
robmathersrobmathers
34.1k3 gold badges71 silver badges105 bronze badges

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

Invoke it like:

Text Editors For Mac Terminal Commands

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).

nohillside

Free Text Editors For Mac

57.1k14 gold badges120 silver badges168 bronze badges
Matt S.Matt S.

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

Evan Kroske
8173 gold badges8 silver badges14 bronze badges
Text Editors For Mac TerminalAlexanderAlexander

Text Edit In Terminal

6,4535 gold badges37 silver badges72 bronze badges

For those finding this post:

The solution was to use the command sudo open -t /path/file.txt

And the man pages for the open command also show how to do some other things like show the file in the finder.

wfbarksdalewfbarksdale

This is not a programming question. But I did a quick google and found this site:

http://ss64.com/osx/pico.html pico: Simple text editor

http://ss64.com/vi.html vi: Text Editor

And this site explains how to use TextEdit from terminal.

SynerCoder

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged macoscommand-lineterminaltextedit .