-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems using native editors via $env:EDITOR with Git for Windows. #3629
Comments
Isn't the real problem, then, that Neovim's defaults for the |
This too, the new cygwin terminal support has almost full support for the new Windows console. However, they may want to support older systems. Further complicating this is that this is the native version of Neovim and not the Cygwin or MSYS2 version (MSYS2 is just Cygwin with a small patch for parameter-destroying.) I should mention that the regular version of native vim does not have this problem, it ignores I will bring this up in the Neovim issue I linked. Regardless, I consider Git modifying Native Windows apps generally don't use |
If native Windows programs don't use |
I tried setting: $env:TERM = 'vtpcon' and that works correctly with Neovim, and Git does not modify it in that case. |
You could use one of the two approaches outlined in https://stackoverflow.com/questions/59733731/how-to-detect-if-running-in-the-new-windows-terminal or microsoft/terminal#6269 to detect in your PowerShell profile that it is running inside a Windows Terminal, and then set `$env:TERM = 'vtpcon':
Of course, you could also change your Windows Terminal PowerShell Profile to execute with a startup command that sets this (I think |
I took a different approach, I am setting: $env:TERM = 'xterm-256color'
$env:COLORTERM = 'truecolor' , in my Both the Windows Terminal and versions of conhost made in the last many years support this just fine. All features I care about including 24 bit color work fine in Neovim. Regular vim also works fine, to the extent that it does on Windows, nano works fine. So I have a solution for my problem and for the document I am maintaining. But that does not solve the issue here, which is I consider this a bug, if you don't, that's for you to decide. Thank you for your work on this project. |
One of the terminal developers confirmed that these are good settings to use, and this works fine with the vim you ship with Git, other than the mouse not working, but that is likely a terminal issue. The mouse does not work in the native regular vim either. |
How could the MSYS2/Cygwin runtime detect that it is connected to a Windows Terminal? FWIW here is what the MSYS2 runtime does: /* If console has 24 bit color capability, TERM=xterm-256color,
otherwise, TERM=cygwin */
if (!sawTERM)
envp[i++] = strdup (wincap.has_con_24bit_colors () ? xterm : cygterm); That |
If you mean to say that https://github.com/git-for-windows/git/blob/v2.35.0.windows.1/editor.c sets |
I also noticed that, and despite looking through the wiki and searching for "windows" in git-config(1), I could not find where this is documented.. @dscho is it documented somewhere ? |
My guess is that 'C:\Windows\notepad.exe' . |
On the original topic,
I agree that it should set |
Did you see my example screenshot? The runtime works correctly, the problem is in Git. I was going to look in |
Here are the PowerShell commands you can test in case someone deleted my screenshot: ri env:TERM,env:COLORTERM -ea ignore
&'/program files/Git/bin/bash' -c 'echo $TERM'
&'/program files/Git/bin/bash' -c 'c:/tools/neovim/neovim/bin/nvim -c ''call writefile([$TERM], fnamemodify("~",":p") . "git-bash-nvim-term.txt")|q'''; gc ~/git-bash-nvim-term.txt |
@rkitover I did, but the second command did not work on my side (syntax error from Vim) :) Thanks for the copy-pasteable commands! |
I mistyped that, sorry, the second command is: &'/program files/Git/bin/bash' -c 'c:/tools/neovim/neovim/bin/nvim -c ''call writefile([$TERM], fnamemodify("~",":p") . "git-bash-nvim-term.txt")|q'''; gc ~/git-bash-nvim-term.txt , I will write an equivalent for regular vim in a few minutes. |
So yeah, that also works for regular vim: &'/program files/Git/bin/bash' -c 'c:/tools/vim/vim82/vim.exe -c ''call writefile([$TERM], fnamemodify("~",":p") . "git-bash-nvim-term.txt")|q'''; gc ~/git-bash-nvim-term.txt . |
On the subject of Windows paths in $env:EDITOR = "'C:/tools/neovim/Neovim/bin/nvim.exe'" , note the extra single quotes. We just need a good solution to do this automatically somehow. |
The second command still does not work for me (sorry, I don't know much about Vim nor Powershell!). If it matters, this is under Windows Powershell (i.e. 5.1). The following command "works": &"$(where.exe git)\..\..\bin\bash.exe" -c "'$(where.exe vim)' -c 'call writefile([$TERM], `"`"term.txt`"`")|q'"; cat term.txt but the resulting file |
OK, I was missing a backtick before TERM: &"$(where.exe git)\..\..\bin\bash.exe" -c "'$(where.exe vim)' -c 'call writefile([`$TERM], `"`"term.txt`"`")|q'"; cat term.txt This does show But, is the environment setup the same when running |
Here is an example I came up with (backup your clone before you do this just in case.) You can do this in any clone. git checkout -b try-branch
git filter-branch --setup 'echo $TERM' --msg-filter cat , you will see that it will output Another test case you can try, make a trivial change in a clone, and run: $env:EDITOR = 'echo $TERM;exit'
git commit -a --verbose this also outputs |
Never mind, I did this wrong. I forgot to run: ri env:TERM,env:COLORTERM -ea ignore , having done this, the So you are right about the problem being with Git in general. |
It also appears to be a problem with the &'/Program Files/Git/usr/bin/awk' 'BEGIN { print(ENVIRON["TERM"]); exit }' , I also get |
So I found the problem: https://github.com/git-for-windows/git/blob/main/compat/mingw.c#L3365 |
Indeed! It dates back to baea068 and this logic was not touched since then as far as I could see. |
A correct syntax for this seems to be: # From Powershell itself
powershell.exe -NoLogo -NoExit -Command '$env:TERM=\"xterm-256color\"'
# or
powershell.exe -NoLogo -NoExit -Command '$env:TERM=''xterm-256color'''
# or
powershell.exe -NoLogo -NoExit -Command "`$env:TERM='xterm-256color'" and in Terminal's "commandline": "powershell.exe -NoLogo -NoExit -Command \"$env:TERM='xterm-256color'\"", |
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See git-for-windows#3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See git-for-windows#3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See git-for-windows#3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See git-for-windows#3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
Setup
Microsoft Windows [Version 10.0.22526.1000]
defaults?
Details
I am using the new Windows Terminal with PowerShell Core.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
I expected Neovim to start with my commit message in the same mode as it starts when run from the PowerShell prompt.
Neovim started with terminal support for Cygwin, with much worse colors etc..
Running the following inside Neovim shows:
, while starting it from PowerShell shows:
The issue is that
$env:TERM
is set tocygwin
when Neovim launches from Git, causing it to use its builtin Cygwin terminal support which is much worse than the nativevtpcon
support for the new Windows console.I opened an issue related to this in the neovim repository:
neovim/neovim#17021
There are two workarounds that I found for this issue, the first is creating a
.bat
file and setting it as$env:EDITOR
.This my
~/.local/bin/nvim.bat
:. Now, the following would work correctly:
. The other workaround is adding the following to
~/.gitconfig
:.
Other Problems with
$env:EDITOR
on Windows$env:EDITOR
does not work at all:The text was updated successfully, but these errors were encountered: