- Best Free Text Editors For Mac
- Text Editors For Mac Terminal Commands
- Free Text Editors For Mac
- 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.
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?
AllanBest Free Text Editors For Mac
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
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 ofTextEdit
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).
Free Text Editors For Mac
♦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 KroskeText Edit In Terminal
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.
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.
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.