Editor for 'git bash' on Windows (editor for mingw/msys+mintty)?
I am using 'git bash' for Windows (from 'git for Windows') which in turn consists of mingw+msys and a mintty.
This mingw installation contains a 'vi' editor which works in the mintty. Good.
Question: Are there any other editors available which run in the mintty terminal emulation window?
The problem is that apparently the mintty terminal window is not a real tty but just uses stdin/stdout to communicate with the application (editor).
Nano just says: 'Redirection is not supported.'. Emacs -nw just says emacs: 'standard input is not a tty'
I would be happy with any basic text editor which has a better user interface than vi.
Solution 1:
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
- Remove the
-nw
fromemacs -nw
in my ~/.gitconfig file and just live with the pop-up emacs; or - 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.
Solution 2:
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.