Skip to content

Instantly share code, notes, and snippets.

@pirogoeth
Created November 28, 2012 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirogoeth/4158675 to your computer and use it in GitHub Desktop.
Save pirogoeth/4158675 to your computer and use it in GitHub Desktop.
locates a directory above the current. used to find project directories in dm. based on lsiden's original.
function dirlocate () {
fDir=$1
sLimit=$2
lDir=""
curdir=`pwd`
while [[ "`pwd`" != "${sLimit}" && "`pwd`" != "/" ]] ; do
if test -e "${fDir}" ; then
cd ${fDir}
lDir=`pwd`
break;
fi
cd ..
done
cd ${curdir}
echo ${lDir}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment