Skip to content

Commit

Permalink
Add $TINYGOROOT to package completion source (#3)
Browse files Browse the repository at this point in the history
(bash only)
  • Loading branch information
sago35 authored Dec 20, 2022
1 parent e6a422a commit 1cc1c44
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions autocmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,24 @@ _tinygo_autocmpl_bash_autocomplete() {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( tinygo-autocmpl %s -- ${COMP_WORDS[@]:1:$COMP_CWORD} )
tinygoroot=$( tinygo env TINYGOROOT )
if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then
tinygoroot=$( cygpath --unix "${tinygoroot}" )
fi
if [ "${opts}" = "" ]; then
compopt -o filenames
COMPREPLY=( $(compgen -f -- "${cur}" ) )
case "${cur}" in
.*)
compopt -o filenames
COMPREPLY=( $(compgen -f -- "${cur}" ) )
;;
*)
compopt -o nospace
for j in $(compgen -f -- "${tinygoroot}/src/${cur}" ); do
COMPREPLY[k++]=${j#${tinygoroot}/src/}
done
;;
esac
else
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
fi
Expand Down

0 comments on commit 1cc1c44

Please sign in to comment.