Skip to content

Instantly share code, notes, and snippets.

@awood
Created June 3, 2019 15:35
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 awood/58bc9ac8cf21567e7a37022cf936296b to your computer and use it in GitHub Desktop.
Save awood/58bc9ac8cf21567e7a37022cf936296b to your computer and use it in GitHub Desktop.
Zsh function to find gradlew by going up through parent directories
#! /bin/zsh
gradleup() {
local curdir="$PWD"
while [[ "`pwd`" != "$HOME" && "`pwd`" != '/' ]]; do
if [[ -e gradlew ]]; then
local result=$(realpath ./gradlew)
break
fi
cd ..
done
cd "$curdir"
if [[ -v result ]]; then
eval "$result $@"
else
echo "gradlew not found"
fi
}
gradleup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment