Editor for 'git bash' on Windows (editor for mingw/msys+mintty)?

Picking up on JFM's answer to a the question How to run emacs in CLI mode under mintty in windows?

JFM points out that the native win32 emacs wants to talk to a Windows console window, not to an actual tty (so the error message we see is misleading, the opposite of what it states is the problem!)

The two immediate options I'm thinking about is

  1. Remove the -nw from emacs -nw in my ~/.gitconfig file and just live with the pop-up emacs; or
  2. Swap from Git Bash to the normal windows command line where the emacs -nw setting works fine.

The advantage for me of the first option is that the Git bash terminal is available across Windows and Mac (and Linux). The advantage of the second option for me is that I can use all my Windows command line knowledge.


The answer https://stackoverflow.com/a/38544424/2416627 points in the right direction – use the winpty command that is distributed with Git for Windows as a prefix for the actual editor command. This works with Emacs and presumably also with Nano.

For Emacs, another workaround is also needed, though, due to a problem with the handling of the Ctrl-C key combination.

First, here is how to configure Emacs in text mode as the default editor – assuming that Emacs has been installed by unpacking the Zip distribution to C:\Program\Emacs:

git config --global core.editor 'winpty /c/Program/Emacs/bin/emacs -nw'

However, in order to be able to quit Emacs using the standard C-X C-C shortcut, the following line must be put in a file named .emacs at the top level of the Windows user profile location of the logged-in user:

(global-set-key [24 pause] (quote save-buffers-kill-terminal))

The same applies to any other shortcuts containing C-C that one wishes to be able to use – i.e. they must be given additional shortcut mappings where "pause" is used in the definition instead of C-C.