Created
June 6, 2012 19:55
-
-
Save josephwecker/2884332 to your computer and use it in GitHub Desktop.
Revisions
-
josephwecker created this gist
Jun 6, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ #!/bin/bash # Put's the script's directory in the $BS variable. # Follows symlinks, works on mac-os as well as linux etc. # Move final popd to the end of your script if you want to run your script with the script's directory as the working directory. BS="${BASH_SOURCE[0]}";RL="readlink";([[ `uname -s`=='Darwin' ]] || RL="$RL -f") while([ -h "${BS}" ]) do BS=`$RL "${BS}"`; done N="/dev/null";pushd .>$N;cd `dirname ${BS}`>$N;BS=`pwd`;popd>$N # ... rest of the script ... use ${BS} when referring to this script's directory