From 1eb69e9a795cc19450178c07d8d382622bc7ad70 Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Fri, 16 Oct 2026 15:19:13 -0300 Subject: first commit --- .../zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .config/zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh (limited to '.config/zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh') diff --git a/.config/zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh b/.config/zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh new file mode 100644 index 0000000..dacc464 --- /dev/null +++ b/.config/zsh/oh-my-zsh/plugins/gradle/gradle.plugin.zsh @@ -0,0 +1,26 @@ +# Looks for a gradlew file in the current working directory +# or any of its parent directories, and executes it if found. +# Otherwise it will call gradle directly. +function gradle-or-gradlew() { + # find project root + # taken from https://github.com/gradle/gradle-completion + local dir="$PWD" project_root="$PWD" + while [[ "$dir" != / ]]; do + if [[ -x "$dir/gradlew" ]]; then + project_root="$dir" + break + fi + dir="${dir:h}" + done + + # if gradlew found, run it instead of gradle + if [[ -f "$project_root/gradlew" ]]; then + echo "executing gradlew instead of gradle" + "$project_root/gradlew" "$@" + else + command gradle "$@" + fi +} + +alias gradle=gradle-or-gradlew +compdef _gradle gradle-or-gradlew -- cgit v1.3