Recursively add subdirectories to path

If you have a bunch of scripts organised in subdirectories, you can add all of them to your path with a single entry in /path/to/your/.profile

after logging on, do

vi /path/to/your/.profile #usually ~/.profile

Then add/replace the following

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="${PATH}:$(find $HOME/bin -type d | tr '\n' ':' | sed 's/:$//')"
fi

You should now be able to run anything in $HOME/bin

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s