Is there a way to make files opened for editing in the terminal open in Textedit instead?
For example, where a command might open a file for editing (like git commit
), instead of opening that file in vim or emacs, it would open in Textedit (or perhaps another text editing application of your choosing, such as Coda or Sublime).
And as a bonus question, is there any way to specifically configure git to automatically open the file created after running git commit
in an editor from the applications directory?
This question is related to
macos
terminal
text-editor
Use git config --global core.editor mate -w
or git config --global core.editor open
as @dmckee suggests in the comments.
Reference: http://git-scm.com/docs/git-config
For Sublime Text 3:
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
See Set TextMate as the default text editor on Mac OS X for details.
make Sublime Text 3 your default text editor: (Restart required)
defaults write com.apple.LaunchServices LSHandlers -array-add "{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}"
make sublime then your default git text editor
git config --global core.editor "subl -W"
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.
Make subl
available.
Put this in ~/.bash_profile
[[ -s ~/.bashrc ]] && source ~/.bashrc
Put this in ~/.bashrc
export EDITOR=subl
For anyone coming here in 2018:
If you want the editor to work with git operations, setting the $EDITOR
environment variable may not be enough, at least not in the case of Sublime - e.g. if you want to rebase, it will just say that the rebase was successful, but you won't have a chance to edit the file in any way, git will just close it straight away:
git rebase -i HEAD~
Successfully rebased and updated refs/heads/master.
If you want Sublime to work correctly with git, you should configure it using:
git config --global core.editor "sublime -n -w"
I came here looking for this and found the solution in this gist on github.
Source: Stackoverflow.com