Created
March 6, 2019 00:59
-
-
Save mtimkovich/aeafbc51d673e9697db8d1a36548aca1 to your computer and use it in GitHub Desktop.
Quickly dive into Java directories
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
dive() { | |
start=$PWD | |
if [ -z "$1" ] || [ ! -d "$1" ]; then | |
return 1 | |
fi | |
cd "$1" | |
while [ true ]; do | |
files=$(find -maxdepth 1 -mindepth 1 -type d) | |
if [ -z "$files" ] || [ $(echo "$files" | wc -l) -ne 1 ]; then | |
break | |
fi | |
cd $(echo "$files" | head -1) | |
done | |
realpath --relative-to=$start $PWD | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment