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.t
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.
The below is listed on Udacity's course on Git and GitHub. It worked for me:
Run the following command in Git Bash after checking the location of Notepad++ on your PC.
echo 'alias npp="C:/Program\ Files\ \(x86\)/Notepad\+\+/notepad\+\+.exe"' >> ~/.bashrc
Notice how I had to escape characters like the space and the brackets. You can escape any character if you're not sure whether it should be escaped or not. Also make sure to use the alias you want; I chose npp
.
Close and re-open Git Bash
npp
in Git Bash, if it opens then you're good to go. If not, try the below points:Test .bashrc by running the command below in Git Bash
source ~/.bashrc
Retry typing npp
to start Notepad++. If Notepad++ doesn't start, check the contents of the file ~/.bashrc created in step 1.
To ensure the .bashrc file contents are loaded each time you open Git Bash, edit ~/.bash_profile and add the following two lines. (Reference)
if [ -r ~/.profile ]; then . ~/.profile; fi
case "$-" in *i*) if [ -r ~/.bashrc ]; then . ~/.bashrc; fi;; esac
Close and re-open Git Bash. Type npp
in Git Bash to check it starts correctly.
This config works for me
editor = \"/c/Program Files (x86)/Notepad++/Notepad++.exe\" -multiInst
The multiInst argument is just to make it friendlier for interactive edits where you already have notepad++ open. (If Notepad++ is already open and you run the process again, it adds the file to your existing instance and then exits immediately, which git takes to mean you've finished)
First of all, if you haven't created any .bashrc profile or .bash_profile create either of the one using vim or any other editor as others have mentioned
Or
In case you did not have any such editor which can work with git bash yet make one manually by opening a notepad or notepad++ editor and saving the file at the home directory.
Note: You can check your home directory by using
cd ~
pwd
My Notepad++ path is C:\Program Files\Notepad++\notepad++.exe
So for going to any directory to notepad++ directory, I have to go to root directory and then to the required path. So here is the line that I had to add to mine .bash_profile
alias note="//\/c/Program\ Files/Notepad++/notepad++.exe"
'//' takes it to the root directory
P.S.:
I met the cannot find the command issue. I figured out that is because I was doing all those vim .bashrc under my working directory. It seems I have to do that under the Git Bash home directory...
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]