Add bash auto-complete

Change-Id: I8733c989133b46e1c7730e507cff23de679f3bb3
This commit is contained in:
Mohammed Naser 2019-12-08 14:44:37 -05:00
parent 8df01ba361
commit 42a6e0876d

11
src.sh
View File

@ -83,3 +83,14 @@ function src {
echo "Could not find or clone $1 - try fully qualifying it"
return 1
}
function _src_completions {
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
SRCSRCDIR=${SRCSRCDIR:-$GOPATH/src}
PROJS=$(find $SRCSRCDIR -mindepth 3 -maxdepth 3 -type d | rev | cut -d'/' -f1,2 | rev | tr '\n' ' ')
COMPREPLY=($(compgen -W "${PROJS}" "${COMP_WORDS[1]}"))
}
complete -F _src_completions src