I have a function which is supposed to remove duplicate copies of directories from my PATH
environment variable. I have created some duplicates so I can test it but I don't know how to:
1) put the script in the $HOME/.bashrc
file
I have a function which is supposed to remove duplicate copies of directories from my PATH
environment variable. I have created some duplicates so I can test it but I don't know how to:
1) put the script in the $HOME/.bashrc
file
Just edit the .bashrc
file (better make a copy of the original first, just in case) and simply add a line the name of the script you want to execute to the file (at the bottom of the .bashrc
would be fine).
If the script is not in your home directory, be sure to specify the complete path.
The right file for environment variables such as PATH
is not ~/.bashrc
but ~/.profile
. .bashrc
is a configuration file for interactive shells; .profile
is the session startup script. See Is there a ".bashrc" equivalent file read by all shells?.
Bash is a bit peculiar with its startup files: in login shells, it reads ~/.bash_profile
if it exists and ~/.profile
otherwise. In interactive non-login shells, it reads ~/.bashrc
. There's no reason not to load interactive settings in interactive login shells, and there are many setups where the session start shell is not invoked as a login shell but ~/.profile
is read explicitly. So make your ~/.bash_profile
contain just these two lines:
. ~/.profile
case $- in *i*) . ~/.bashrc;; esac
If you had things in ~/.bash_profile
, move them to ~/.profile
if they are things like environment variable settings, and to ~/.bashrc
if they are interactive shell configuration such as aliases and key bindings.
Put all your PATH
manipulation in ~/.profile
.
.profile
- it just means it hasn't been created yet, and that's absolutely fine. If you need to create it, go right ahead and use gedit's tools to do so. – D_Bye Jun 15 '12 at 09:38