I know this is total n00b stuff but I always forget the particular so I thought I’d write it down in a blog entry.
To add a custom scripts directory to your path, do the following:
In your root directory, create a file called .bash_profile
with something like the following:
if [ -f $HOME/.bashrc ]; then      . $HOME/.bashrc fi
Then in .bashrc
, put something like the following:
export PATH=$PATH:$HOME/Scripts
Make both scripts executable:
chmod +x .bash*
For extra credit, create a softlink from your Dropbox folder to your scripts folder and you can have the same scripts on all of your computers!
ln -s $HOME/Scripts $HOME/Dropbox/Scripts
Hey Bill,
I think it is good practice to use $HOME instead of ~ within scripts. At least in some situations, ~ is expanded on the shell command line but not elsewhere. Obviously it isn’t causing you a problem here but it bit me somewhere that I can’t remember at the moment.
I second Jim’s comment about tilde (~) versus $HOME, specifically on SunOS/Solaris the ~ is not expanded when using something like scp.
Also, you mentioned using .bash_profile.sh, did you mean .bash_profile? I’ve never used an OS that utilizes .bash_profile.sh, just curious if that’s your case.
quite often the default script includes ~/bin on the path if present. So you could just create ~/bin and keep your scripts there.
Thanks all. I’ve updated the post based on your comments.
– Changed name of .bash_profile.sh to .bash_profile
– Changed tildes to $HOME