Skip to content

Instantly share code, notes, and snippets.

@mtimkovich

mtimkovich/dive.sh

Created Mar 6, 2019
Embed
What would you like to do?
Quickly dive into Java directories
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