Created
November 28, 2012 02:34
-
-
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.
This file contains 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 characters
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