9

I'm trying to get Neovim to work in Git bash. When I type nvim in cmd, everything works as expected and it opens Neovim, when I do the same in the Git bash, the whole editor just turns blank until I CTRL+C out of it. I suppose that there might be some pathing problem, but I'm not sure. I attached some images as well.

I've tried to add the path to Neovim in gitconfig in the Git folder and in the home folder as well.

which nvim gives: /c/Program Files/Neovim/bin/nvim

image1 - Gitbash

image2 - Gitbash

Cmd - works

2

2 Answers 2

3

Got it working and found two solutions.

  1. Reinstall bash and set Neovim as a default editor during the installation (Git has a test feature to make sure your editor is working even during installation)
  2. in $home find .gitconfig and add the path to your editor, but use two escapes \\ when there is space, e.g. C:/Program\\ Files/...
3
  • 8
    I think the issue has to do with tty. I'm experiencing the same issue but reinstalling git bash doesn't seem to work. However, running winpty nvim does
    – CervEd
    Mar 7, 2021 at 15:42
  • 4
    I experienced the same issue and made an alias for nvim wrapping 'winpty nvim', and it works on my Git for Windows installation. Many thanks! Jun 22, 2022 at 0:12
  • I also wrapped some commands with winpty {command} - which is very handy. But still - don't like that I had to do that in the first place ... :( Mar 27, 2023 at 17:53
2

Create an alias by editing the .bashrc file with the following command:

vi .bashrc

Then create an alias by placing the following text into the editor:

alias nvim="winpty nvim"

Go to normal mode by pressing ESC then save the file with :wq command. The final step is to apply the changes using this command:

source .bashrc
6
  • 1
    Welcome and thank you for posting an answer. Could you please provide a reference regarding the behavior of echo \ ? BTW, an alternative would be to put the alias in .bashrc using an editor. I'd recommend a vi clone.
    – Friedrich
    Jul 5, 2023 at 14:34
  • I agree, using an editor is a less hacky way to create an alias. I am going to edit the answer that uses the vi command. Jul 6, 2023 at 7:32
  • I wouldn't say "hacky"... but I'd want to stay in control of my .bashrc. Actually, I'm still curious about the echo \ thing. Man pages say nothing about it. If anything, \a should be interpreted as BELL as far as I've seen. When I tried, the leading backslash did not seem to do anything.
    – Friedrich
    Jul 6, 2023 at 7:49
  • Well, it was a trial-and-error kind of thing. First, I started the echo command with \ (inspired by the markdown syntax) character. Then I saw that it adds a space to the config file therefore I got rid of it. So I ended with the weird: echo \alias... command that I do not really like in retrospect. Jul 6, 2023 at 8:03
  • Thank you for clarifying.
    – Friedrich
    Jul 6, 2023 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.