Invoking notepad++ from Git Bash

后端 未结 14 2582
隐瞒了意图╮
隐瞒了意图╮ 2021-01-31 16:01

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

14条回答
  •  南旧
    南旧 (楼主)
    2021-01-31 16:22

    The below is listed on Udacity's course on Git and GitHub. It worked for me:

    1. 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.

    2. Close and re-open Git Bash

    3. Type npp in Git Bash, if it opens then you're good to go. If not, try the below points:
    4. Test .bashrc by running the command below in Git Bash

      source ~/.bashrc
      
    5. Retry typing npp to start Notepad++. If Notepad++ doesn't start, check the contents of the file ~/.bashrc created in step 1.

    6. 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
      
    7. Close and re-open Git Bash. Type npp in Git Bash to check it starts correctly.

提交回复
热议问题