Skip to content

Instantly share code, notes, and snippets.

@hartsock
Created January 12, 2012 16:31
Show Gist options
  • Save hartsock/1601457 to your computer and use it in GitHub Desktop.
Save hartsock/1601457 to your computer and use it in GitHub Desktop.
A shell script to automatically add any command line utility to your path works with any OS that uses BASH
#!/bin/bash
# relies on the conventions:
# 1. all tools go into ~/tools
# 2. all tools are configured with a 'current' symlink for
# the currently in-use version
# 3. all tools have a 'bin' directory
# for example: to upgrade from grails 1.3.6 to 1.3.7
# $ cd ~/tools/grails
# $ rm current
# $ ln -s grails-1.3.7 current
# for example: put STS on your CLI
# 1. install STS into tools/springsource
# 2. create empty directory tools/springsource/current
# 3. ln -s tools/springsource/sts-2.8.1.RELEASE tools/springsource/current/bin
for file in $HOME/tools/*
do
if [ -d $file ]; then
bindir="$file/current/bin"
if [ -d "${bindir}" ]; then
PATH="$bindir:$PATH"
fi
fi
done
export PATH
@hartsock
Copy link
Author

On OS X I put the following line in ~/.profile:

source $HOME/bin/tools.sh

On linux I add that line to ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment