Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm learning to program. While following this mission, I typed git commit, which opened up vim. I don't know or want to know vim (no offense to vim lovers). I'd like to have:

  1. terminal open gedit ever time it try to do text editing from the terminal; and
  2. gedit release the terminal for further use.

How do I do that?

UPDATE:

Ok. I'm close, but I must be missing something.

Added /Applications/gedit.app/Contents/MacOS/ to /etc/paths

Because I wasn't root, I had to save it to my desktop. Then I had to move it to /etc, so, terminal handled that.

sudo mv paths /etc

Then I changed the editor.

git config --global core.editor "gedit"

after typing

git commit

I received.

error: cannot run gedit: No such file or directory
error: There was a problem with the editor 'gedit'.
Please supply the message using either -m or -F option.

UPDATED 2: Relaunching terminal fixed the problem.

Thanks everyone.

share|improve this question
3  
You really should learn vim well enough for basic text editing. It's an important skill for a programmer. GUI editors are nice and all, but sometimes a command line editor is the only choice and vim is a perfectly good one. I'm not saying you should use it for git messages, but you should know how it's done. "I don't know or want to know vim" is a stupid attitude. It should be "I prefer not to use vim, but I can when it's the best option". –  Abhi Beckert Mar 4 '12 at 3:05
3  
I was making the statement "I don't know or want to know vim" to avoid getting answers on how to use vim. It's the perfect attitude if you want to clearly state what you don't want. I have no problem with vim or learning vim in the future, but my ineptitude with non-GUI text editors was causing more problems than help. Since everything regarding programming is new for me, I have to pick my battles and a non-GUI text editor wasn't going to be one of them today. –  Dorje Mar 4 '12 at 3:22
1  
In should only take you five minutes to learn enough about vim to type a git message. And learning vim is a lot easier than figuring out how to integrate a GUI text editor into the command line, and in many common situations it's impossible. Anyway, I just wanted to point out you should put vim on your to-do list as something to learn one day. Preferably soon. –  Abhi Beckert Mar 4 '12 at 3:28
    
If you put the line export EDITOR=gedit in ~/.bash_profile, then EVERY command line program that wants you to edit something will open it in gedit. Also, you should try out nano, which is a very simple CLI text editor, and should also be present on most nixes. (It is included by default on Mac OS X.) It is much more like a *normal text editor, and all the commands are listed in two lines at the bottom of the window. (You will probably find it more convenient for git commits, for example, because you won't have to jump from window to window.) –  daviewales Dec 6 '13 at 13:14
add comment

3 Answers

up vote 1 down vote accepted

In order to do this, type
open -a gedit path/to/file
to open and run the gedit application (using the -a switch issues a command to look for gedit in your /Applications directory).

Alternatively, add
/Applications/gedit.app/Contents/MacOS/
to your $PATH, which should allow you to open gedit from the terminal as well by simply typing gedit

share|improve this answer
    
Yes. Those help when I'm in control, but will it help with situations where I'm not in control - like with the git commit command? Also, where would I find the $PATH file? –  Dorje Mar 4 '12 at 1:05
    
$PATH is a variable usually set in your .bashrc file –  MrDaniel Mar 4 '12 at 1:14
    
This fixed it. Thanks. –  Dorje Mar 4 '12 at 2:49
    
@Dorje, if my answer solved your problem, please click "accept answer" on the left side of my answer. Glad this helped! –  soxman Mar 7 '12 at 21:26
add comment

You should edit your git configuration file regarding which editor to use.

As noted here How do I make git use the editor of my choice for commits?

From man git-commit:

ENVIRONMENT AND CONFIGURATION VARIABLES

The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order).

share|improve this answer
    
setting EDITOR or VISUAL will allow you to use that editor from any command line program –  Mark Mar 4 '12 at 1:05
    
Yes, you usually want to set EDITOR - this is used by many other VCS, such as CVS or SVN. –  cm2 Mar 4 '12 at 1:27
    
This fixed it. Thanks. –  Dorje Mar 4 '12 at 2:49
    
@cm2 - not just VCS but other processes. –  Mark Mar 4 '12 at 18:56
    
@Mark Ooops, I meant 'many other programs including VCS...'! Indeed, these are used by lots of programs. –  cm2 Mar 4 '12 at 23:22
add comment

See this post http://eddieringle.com/how-to-properly-configure-git-to-use-gedit-as-its-default-editor/

and excerpt below

git config --global core.editor "gedit -w -s"
    -w: wait for Gedit to save the file and exit before continuing
    -s: runs that instance of Gedit in standalone mode to let gedit return after that window is closed.
share|improve this answer
1  
Did you verify that this works on OS X? –  patrix Oct 21 '12 at 9:10
    
I do not have OS X but verifying in Linux I though it might be helpful for others to know about it to give it a try. –  gunalmel Jan 9 '13 at 5:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.