Guandalino, I'm confused by question 2 (since removed from the question since it was due to an unrelated issue):
What's a workable way to append more paths on different lines? Initially I thought this could do the trick:
export PATH=$PATH:~/opt/bin export PATH=$PATH:~/opt/node/binbut it doesn't because the second assignment doesn't only append
~/opt/node/bin, but also the wholePATHpreviously assigned.This is a possible workaround:
export PATH=$PATH:~/opt/bin:~/opt/node/binbut for readability I'd prefer to have one assignment for one path.
If you say
PATH=~/opt/bin
that's all that will be in your PATH. PATH is just an environment variable, and if you want to add to the PATH, you have to rebuild the variable with exactly the contents you want. That is, what you give as an example to question 2 is exactly what you want to do, unless I'm totally missing the point of the question.
I use both forms in my code. I have a generic profile that I install on every machine I work on that looks like this, to accommodate for potentially-missing directories:
export PATH=/opt/bin:/usr/local/bin:/usr/contrib/bin:/bin:/usr/bin:/usr/sbin:/usr/bin/X11
# add optional items to the path
for bindir in $HOME/local/bin $HOME/bin; do
if [ -d $bindir ]; then
PATH=$PATH:${bindir}
fi
done