16

I am using git version 2.7.0.windows.1 on a windows pc, I used the following command:

$ nano README

which results me:

bash: nano: command not found

Now how can I install nano text editor to git bash?

jmiserez
  • 2,991
  • 1
  • 23
  • 34
Rubel Hassan
  • 186
  • 1
  • 1
  • 9

5 Answers5

13

Little modification of the previous solution (@Simopaa) is worked for me on Windows 10 (without Chocolatey):

  1. Download nano-git
  2. Move the nano-git-xxx.exe to (for example) C:\Program Files\Git\bin.

  3. Modify the .gitconfig file with the following (single and double quotes are important):

    [core]
    editor = "winpty '/c/Program Files/Git/bin/nano-git-0d9a7347243.exe'"
    
  4. (Optional step) Make nano available for editing in general:

    Create or edit the one of the startup script of bash (e.g. ~/.bash_profile) with the followings:

    export PATH="/c/Program Files/Git/bin:$PATH"
    alias nano="winpty nano"
    
aszoke
  • 380
  • 3
  • 10
8

If anyone's still struggling with this, here's how I managed to get it working.

  1. Download nano-git from https://www.nano-editor.org/dist/win32-support/
  2. Move the exe to (for example) C:\Program Files\Git\bin. I renamed it to nano.exe.
  3. Run nano in bash with winpty nano
  4. Add the following to .gitconfig to make nano your default editor:

[core] editor = winpty C:/Program Files/Git/bin/nano.exe

There might be a more elegant solution, but this works for me.

Simopaa
  • 449
  • 5
  • 8
  • 2
    I get errors when I specify `C:/Program Files/Git/bin/nano.exe` (winpty does not like the spaces in the path - even if I surround it with double quotes). I fixed my error by specifying just `nano.exe`, which I installed using Chocolatey with the command `cinst nano`. – Colin Aug 14 '17 at 20:00
3

If you already have nano install in your system, you just need to add the path of the exe file to PATH.

To do it just for Git bash, you can open GITINSTALL_DIR\etc\profile with any text editor and add this line to it:

export PATH="/DriveLetter/PATH/TO/YOUR/NANO:$PATH"

Of course you need to change the path above according to your case.

If you havn't installed it yet, just download and put it under GITINSTALL_DIR\bin or any folder included in $PATH

gdlmx
  • 6,479
  • 1
  • 21
  • 39
  • The question was how to install it. I presume that the usual way of installing it (I don't know what that is) will put the executable in the default `$PATH`. – Keith Thompson Apr 22 '16 at 20:51
  • [`nano`](https://www.nano-editor.org/) is a simple editor, designed with [`pico`](https://en.wikipedia.org/wiki/Pico_(text_editor)) users in mind. – tripleee Jul 29 '16 at 05:45
0

When you install the new version of git you can choose the editor nano.

foloin
  • 11
  • Installing the latest Git and choosing nano as the default editor worked for me when these other solutions did not. – trebormf Jan 29 '19 at 19:44
0
  1. Download nano for Windows

  2. Rename the file to nano.exe

  3. Move it to C:\Program Files\Git\usr\bin

  4. Open git for Windows and issue the following command:

git config –global core.editor “winpty nano”

Toni Zeidler
  • 163
  • 1
  • 11