Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Created March 6, 2019 00:59
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 mtimkovich/aeafbc51d673e9697db8d1a36548aca1 to your computer and use it in GitHub Desktop.
Save mtimkovich/aeafbc51d673e9697db8d1a36548aca1 to your computer and use it in GitHub Desktop.
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