which one of these files do I have to edit so that I can launch Notepad++ from my cygwin Terminal?
$ find -name ".*"
.
./.bashrc
./.bash_history
./.bash_profile
./.inputrc
./.profile
This is the command I give in the terminal to add the Notepad++ to the directory
$ export PATH=$PATH:/cygdrive/c/Program\ Files\ \(x86\)/Notepad++/
So if i do a echo $PATH I can see that the directory was added to my PATH
This then allows me to open files in Notepad++ for editing
$ notepad++.exe filename
But i want my cygwin to be like this everytime I launch it. How can this be done?
NOTE: Using cygwing on windows7
There are also another ways to do what you want. You don't have to add Notepad's directory to the PATH, when you need only one executable from that directory. The main advantage of a directory in the PATH is that every executable in that directory is available anywhere.
You can use for example alias, symbolic link or function. Each method creates the "npp" command, which you can then use as you suggested: npp filename. Advantage over the PATH method is that you can name it whatever you want.
alias
alias npp='/cygdrive/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe'
You can put it for example to your .bashrc. You can also add a parameters to an alias command. The name of an alias can be whatever you want.
symbolic link
ln -s /cygdrive/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe /usr/local/bin/npp
This will create a file in the directory /usr/local/bin which is already in your PATH. This file is symbolic link (something like Windows' shortcut) to the Notepad++ executable. The name of a symbolic link (the last part of the command) can be whatever you want, but you can't use a parameters there.
General format of the ln command for symbolic link:
ln -s target link_name
function
npp () {
/cygdrive/c/Program\ Files/Notepad++/notepad++.exe $(cygpath -w -- "$#")
}
Again, you can put it for example to your .bashrc and name it whatever you want. cygpath converts path to the file from Linux to the Windows format, but it should not be necessary.
By editing ./bashrc file, you can achieve your goal. Here is the link for Cygwin Tutorial: Use External Editor Notepad.
Related
When I use command sudo vipw to edit my password file, It's always use vi as editor. I don't like this very much and want to change it to vim.
I already tried:
Add export EDITOR=/usr/local/bin/vim in /etc/profile.
But shell told me "export: Command not found". I thought the reason is export is built-in function only in bash. And I don't want to change my shell.
AddEDITOR=/usr/lcoal/bin/vim in default block of /etc/login.conf
Add setenv EDITOR vim in /root/.cshrc, /.cshrc, ~/.cshrc
All above didn't work at all.
I have google for hours but could not find anything help.
Your /etc/sudoers file doesn't keep your EDITOR environment variable.
I personally have an /etc/sudoers.d/local file, something like
# We don't need to worry about wheel users breaking in to get root access because they already have it.
Defaults:%wheel env_keep+="HOME EDITOR",!set_home,shell_noargs
I'm not sure why this isn't the default, since wheel users have already been given full access. But it's apparently prevailing wisdom to continue hassling them.
Note: If you're using an older /etc/sudoers file that doesn't support an /etc/sudoers.d directory, these lines can be dropped in there... or you could add #includedir /etc/sudoers.d as the last line of your /etc/sudoers file to enable an /etc/sudoers.d directory. Um, yes, the # is a required part of that line, because someone thought it was important for that directive to look like a comment.
Try adding this to the root user /root/.chsrc:
setenv EDITOR vim
or to set it globally to all users using shell tcsh/csh add it in /etc/csh.cshrc
From the man:
A login shell begins by executing commands from the system files /etc/csh.cshrc
and /etc/csh.login. It then executes commands from files in the user's home directory:
first ~/.tcshrc or, if ~/.tcshrc is not found, ~/.cshrc ...
Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on startup.
Also verify vim is installed since is not by default, you could try:
pkg install vim-console
setting the EDITOR or VISUAL environment variable is the key.
if you don't want to go to the trouble of modifying config files (which is indeed the long term solution) then you could sudo su - to get to the root prompt and then you could export EDITOR=/usr/bin/vim before running vipw
There is an empty file called .selected_editor in $HOME (/root).
Remove it and the next call to vipw will ask you to select the editor.
I'm trying to extend my $PATH variable in git bash (MinGW shell) by adding the following to the file ~/.bashrc
PATH=$PATH':/c/Program Files/maven/apache-maven-3.2.5/bin'
After I did this and restarted the bash it seems like that the $PATH variable was extended like expected:
$ echo $PATH
MANY_OTHER_PATHS:/c/Program Files/maven/apache-maven-3.2.5/bin
But I still cannot execute the programms in the given directory:
$ mvn
bash: mvn: command not found
What went wrong here? How do I extend the PATH variable correctly?
Here are two ideas.
You can have your path with double quote mark.
export PATH=$PATH:"/C/Program Files (x86)/apache-maven-3.3.3/bin"
Or, You can also make symbolic link for the directory.
ln -s "/C/Program Files (x86)/apache-maven-3.3.3/bin" ./mvnbin
export PATH=$PATH:/your-path/mvnbin
It works for me in mingw32 environment.
I needed to add something to my Git Bash path permanently each time I open it. It was Meld.exe path which can be added with:
export PATH=$PATH:"/C/Program Files (x86)/Meld/lib"
In order to execute this command each bash session, you need a ~/.bashrc file. Check if it already exists or create it using notepad ~/.bashrc or touch ~/.bashrc.
You can check where it is with:
echo ~
Open it and add the command that adds the PATH (first command in this response).
I hope you found this useful.
According to this SO post, you need to escape Program Files with quotes. git-bash $PATH cannot parse windows directory with space
Add PATH in Git Bash Permanently | Windows Only
Just in case you are still wondering how to add a path permanently in git bash here is the step-by-step process for Windows users:
Create .bashrc in user's root folder using the below command. It will open notepad and ask you to create the file, click yes.
notepad ~/.bashrc
Put the directory you want to add as below, for more than 1 items repeat the same format in next line:
export PATH=$PATH:"/c/folder/folder/"
Save the file and relaunch the bash.
Next launch will give you a warning like WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile. but git bash will handle it by creating the required files.
SOME INSIGHTS
Git Bash doesn't fetch Window's environment PATH, it maintains its PATH separately in more like a Linux way.
You can run export PATH=$PATH:"/c/folder/folder/" in cmd to add a directory to path, but it will be only for the current session once you close the bash, it will be gone.
.bashrc is a shell script file that will be executed every time you launch a new git bash window. So you can add any type of bash command here. We simply added the export command to add our desired directory to PATH.
I have one python command file, i want to set it as a PATH in Solaris Sparc so that i can easily use my command from anywhere. For example the file name is abc.py and it contains abc --version to display version of file abc. So, after opening terminal i should only give command abc --version and it should display version of abc.
The architecture (SPARC) has nothing to do with the PATH which is more a shell thing but you do not tell what shell you are using.
Anyway, if you use a bourne style shell, i.e. not csh/tcsh, and you don't mind this to affect every user account on that host, you might add the wanted path to the PATH setting in the file /etc/profile.
When abc.py is located in your homedir, you can start it with ~/abc.py.
You need to call the file abc.py with abc.py, not abc (and have a shebang line which instructs the shell where it can find python).
When you want to start the file with ./abc, you can rename the file to abc (the shebang will tell it is python, not the .py), or introduce an alias:
alias abc="~/abc.py"
Using an alias can be an alternative for adding a shebang line:
alias abc="/usr/bin/python abc.py"
When you do not want to use an alias you can make a bin dir and put abc there.
I will add the shebang for you:
mkdir ~/bin
echo "#!/usr/bin/python" > ~/bin/abc
cat abc.py >> ~/bin/abc
chmod +x ~/bin/abc
mv abc.py bin/abc.py.old
Now change your login PATH with PATH=${PATH}:$HOME/bin in your .profile or .bashrc, and login again (or source the login script).
I am installing software on my MacBook Pro in preparation for a Rails tutorial. One of the steps involves creating a symbolic link to Sublime Text 2 so that it can be used in Bash. To do this, Sublime Text advises
The first task is to make a symlink to subl. Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
When I run this command, I get
ln: /Users/nngrey/bin/subl: No such file or directory
My path seems to include ~/bin:
echo $PATH
/Users/nngrey/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin:/Users/nngrey/.rvm/gems/ruby-2.0.0-p247#global/bin:/Users/nngrey/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/nngrey/.rvm/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Any suggestions?
Thanks
Your $PATH does not, in fact, contain ~/bin. If you look closely, /Users/nngrey/bin is not there. The original ln -s ... command probably failed because ~/bin doesn't exist. To make it, run mkdir ~/bin from Terminal. Then, rerun the ln command. Finally, run ~/bin/subl ~/.profile to open your ~/.profile file in Sublime, and add the following line to the bottom:
export PATH=$PATH:~/bin
Save the file, then restart your Terminal session and you should be able to type subl filename from the command line in any directory.
I just started reading Michael Hartl's book on Rails and I've run across a problem in the setup phase. Hartl keeps referring to making a file in my home directory, but I'm not quite sure how to do this. For example, when I try to setup the command line for sublime text the instructions tell me to do this: Assuming you've placed Sublime Text 2 in the Applications folder, and that you have a ~/bin directory in your path, you can run:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
My problem is that I don't know how to put a ~/bin directory in my path. I know this is real basic but any help would be greatly appreciation.
create or edit ~/.profile (works with both bash and zsh)
add the following
export PATH=$PATH:$HOME/bin
The line above is saying, overwrite the PATH environment variable and set it to the previous path plus ~/bin
Now when you try to run a command, bash will look in all the colon separated paths in your PATH environment variable for an executable.
To see your entire PATH, type echo $PATH in a terminal. Or better yet, type env to see all environment variables.
On your terminal
$ mkdir ~/bin
$ sudo ln -s "/Applications/Sublime Text2.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Edit ~/.base_profile
export PATH=$PATH:~/bin
usage:
open current directory:
subl .
In your ~/.bashrc file add to the end:
PATH="$HOME/bin:$PATH"