From 622911b91ef8ca4a02e34b1c471b92cba2dd4326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 8 May 2024 13:23:13 +0300 Subject: [PATCH] gg.sh: fix completion --- shared/home/gg.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/home/gg.sh b/shared/home/gg.sh index 4ca1359..e305a98 100644 --- a/shared/home/gg.sh +++ b/shared/home/gg.sh @@ -31,6 +31,8 @@ gg() { # g() { local pkg_candidates + local _gopath + _gopath=$(git rev-parse --show-toplevel) pkg_candidates="$( (cd "$_gopath" && find . -mindepth 1 -maxdepth ${_GG_MAXDEPTH} -type d -path "*/$1" -and -not -path '*/vendor/*' -print) | sed 's/^\.\///g')" echo "$pkg_candidates" | awk '{print length, $0 }' | sort -n | awk '{print $2}' } @@ -41,6 +43,8 @@ _g_complete() { COMPREPLY=() local cur cur="${COMP_WORDS[COMP_CWORD]}" + local _gopath + _gopath=$(git rev-parse --show-toplevel) COMPREPLY=($(compgen -W "$(for f in $(find "$_gopath" -mindepth 1 -maxdepth ${_GG_MAXDEPTH} -type d -name "${cur}*" ! -name '.*' ! -path '*/.git/*' ! -path '*/test/*' ! -path '*/vendor/*'); do echo "${f##*/}"; done)" -- "$cur")) return 0 }