views:

34

answers:

3

It there a way to make files opened for editing in the terminal open in Textedit instead? I mean, where a command might open a file for editing (like git commit), instead of opening that file in vi or emacs, it would open in Textedit (or perhaps another Textediting application of you choosing, such as Coda).

And as a bonus question, is there anyway to configure git to automatically open the file made after running git commit in an editor in the applications directory.

+1  A: 

Set your editor to point to this program:

/Applications/TextEdit.app/Contents/MacOS/TextEdit

With SVN, you should set SVN_EDITOR environment variable to:

$ export SVN_EDITOR=/Applications/TextEdit.app/Contents/MacOS/TextEdit

And then, when you try committing something, TextEdit will launch.

Pablo Santa Cruz
I'd prefer to use `/usr/bin/open`, because that will use the finder default *whatever* you set it to.
dmckee
+1  A: 

Most programs will check the $EDITOR environment variable, so you can set that to the path of TextEdit in your bashrc. Git will use this as well.

mathepic
Could someone provide a quick walk through of how to do this/where to find the variable?
Diogenes
+1  A: 

Use git config --global core.editor mate -w or git config --global core.editor open as @dmckee suggests in the comments.

Reference: http://www.kernel.org/pub/software/scm/git/docs/git-config.html

Ionuț G. Stan
...and setting it to use `open` means that you automatically get the finder default. So changes in the finder are propagated naturally.
dmckee
@dmckee nice trick.
Ionuț G. Stan
`open` uses Launch Services to determine the file type, mostly based on its extension. If the file has an unknown extension, it'll fail to open the file. Generally, your CLI editor should be something that assumes text files...
Gordon Davisson
How do I set it to use open?
Diogenes