I am using msysgit in Windows 7. How do I invoke notepad++ from Git Bash, like we do it with our default notepad?

Like for example

name@usename notepad textfile.txt

Instead I want the file to open with notepad++.

Note : I've added notepad++ to my PATH, but still unable to invoke it from commandline.

Edit

I tried this in .gitconfig -->

[alias] notepad='C:/Program Files/Notepad++/notepad++.exe'

but isn't working.


So, by default you won't have a .bashrc file so just navigate your to your home directory by typing:

cd ~

create or edit the .bashrc with vim (or whatever editor you are comfortable with):

vim .bashrc

Here is the line I had to add to mine (I am running a 64 bit OS so if you aren't don't copy this exactly)

alias notepad="/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"

If your copy of windows is 32 bit then it should look like this

alias notepad="/c/Program\ Files/Notepad++/notepad++.exe"

Finally, close and reopen your terminal/bash (or, as noted, run source ~/.bashrc), and voila!


these are the faster ways to achieve the goal

start notepad++ 
start notepad++ <filename>
alias np='start notepad++'
np <filename>

tried and tested, just do it!


I added this for my 64-bit machine with 32-bit Notepad++.

$ cd ~
$ vim .bash_profile

Add this to the file then save:

64-bit systems

alias npp="/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"

32-bit systems

alias npp="/c/Program\ Files/Notepad++/notepad++.exe"

Now you should be able to open any file with notepad++ by entering

$ npp [file_name]

I believe git-bash is an actual bash shell, so when it starts, it runs a .bashrc file from somewhere (most likely your home directory or the directory git-bash starts in). Look for that file, and when you find is, add an alias line somewhere for notepad++:

alias notepad="/c/Program\ Files/Notepad++/notepad++.exe"

Of course use your actual path to Notepad++ there.


@SageMage's answer is right on spot.

Just a reminder. You need to close and reopen GitBash after after you make a change in .bashrc in order for it to be activated.

PS: After two years, I hope this helped!