Skip to content

Problems using native editors via $env:EDITOR with Git for Windows. #3629

Closed
@rkitover

Description

@rkitover

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
git version 2.34.1.windows.1
cpu: x86_64
built from commit: 2ca94ab318509b3c271e82889938816bad76dfea
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
Microsoft Windows [Version 10.0.22526.1000]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

I am using the new Windows Terminal with PowerShell Core.

$env:EDITOR = 'C:/tools/neovim/Neovim/bin/nvim.exe'
git commit -a --verbose --signoff -S
  • What did you expect to occur after running these commands?

I expected Neovim to start with my commit message in the same mode as it starts when run from the PowerShell prompt.

  • What actually happened instead?

Neovim started with terminal support for Cygwin, with much worse colors etc..

Running the following inside Neovim shows:

:echo $TERM
" cygwin
:echo &term
" builtin_cygwin

, while starting it from PowerShell shows:

:echo $TERM
" vtpcon
:echo &term
" builtin_vtpcon

The issue is that $env:TERM is set to cygwin when Neovim launches from Git, causing it to use its builtin Cygwin terminal support which is much worse than the native vtpcon 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:

@echo off
set TERM=
/tools/neovim/neovim/bin/nvim %*

. Now, the following would work correctly:

$env:EDITOR = 'C:/Users/rkitover/.local/bin/nvim.bat'
git commit -a --verbose --signoff -S

. The other workaround is adding the following to ~/.gitconfig:

[core]
    editor = sh -c "'"TERM= c:/tools/neovim/Neovim/bin/nvim.exe \"$@\""'" --

.

Other Problems with $env:EDITOR on Windows

  • A normal Windows path with backslashes in $env:EDITOR does not work at all:
$env:EDITOR = 'C:\tools\neovim\Neovim\bin\nvim.exe'
git commit -a --verbose --signoff -S
hint: Waiting for your editor to close the file... C:\tools\neovim\Neovim\bin\nvim.exe: C:toolsneovimNeovimbinnvim.exe: command not found
error: There was a problem with the editor 'C:\tools\neovim\Neovim\bin\nvim.exe'.
Please supply the message using either -m or -F option.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions