Created
April 23, 2015 15:16
-
-
Save poweld/d581538084c6372fac5f to your computer and use it in GitHub Desktop.
Go to a directory within the current path
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 cd..() { | |
if [ -z $1 ]; then | |
cd .. | |
else | |
grep "\/" <<<$1 &>/dev/null | |
if [ $? -eq 0 ]; then | |
echo "Invalid filename" | |
return | |
fi | |
grep $1 <<<`pwd` &>/dev/null | |
if [ $? -eq 0 ]; then | |
pushd . &>/dev/null | |
while [ $(basename `pwd`) != $1 ]; do | |
cd .. &>/dev/null | |
done | |
popd &>/dev/null | |
cd - &>/dev/null | |
else | |
echo "Could not find $1 in path to current working directory" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment