Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sh.exe": emacs: command not found (Git bash Windows)

I'm using Git Bash on Windows 7 and have a problem with setting up emacs as the default text editor - I've tried git config --global core.editor emacs, then git config --global core.editor "'C:/emacs-23.3/bin/runemacs.exe'", git config --global core.editor emacsclientw but to no avail. Each time I enter something like 'emacs README.txt' in Bash, the below error shows:

sh.exe": emacs: command not found

I've put up with this for the longest time, choosing to just open up emacs separately and opening up the related file, but this time I really want to set things up properly so that I can save time and simply invoke emacs from Git Bash. Does anyone know what I can do? Thanks in advance for your help.

like image 813
anthonytwp Avatar asked Apr 19 '12 02:04

anthonytwp


2 Answers

You need to ensure the emacs bin directory is on the PATH so that the binary can be found when just entering emacs or emacsclient. You can set the default editor for most unix type tool to use your current emacs session by setting the environment variable EDITOR to emacsclient. You should use emacsclient rather than emacsclientw because you need the launching tool to wait for the edit to be completed and they do that by waiting for the editor to exit. If you only want git to use this then git config --global core.editor emacsclient would do the job, or setting GIT_EDITOR=emacsclient in the environment.

In summary:

PATH=c:\emacs-23.3\bin;%PATH%
EDITOR=emacsclient
export PATH EDITOR

or fix the equivalents in the Windows system environment.

like image 169
patthoyts Avatar answered Sep 28 '22 19:09

patthoyts


You can also try the magit, which is amazing to use Git in emacs. You can get it from https://github.com/magit/magit

like image 26
csophys Avatar answered Sep 28 '22 18:09

csophys