it would be great to add contextual autocompletion features to the options.
i came up with a basic bash script with some stuff (it autocomplete with commands, and with installed versions after the -u flag or uninstall command):
_u3d()
{
local cur prev commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case o"${prev}" in
o-u)
local versions="$(u3d list | sed 's/^Version \([0-9\\.abfp]*\).*$/\1/')"
COMPREPLY=( $(compgen -W "${versions}" -- ${cur}) )
return 0
;;
esac
if [[ i"${COMP_CWORD}" = i1 ]] || [[ i"${COMP_CWORD}"x"${prev}" = i2xhelp ]];then
commands="available credentials help install list prettify run uninstall"
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
fi
case i"${COMP_CWORD}"x"${prev}" in
i2xinstall)
#TODO display fetched versions?? 'u3d available' may need to refresh and be too slow. is there a flag to skip refreshing?
local versions="latest latest_stable latest_beta latest_patch"
COMPREPLY=( $(compgen -W "${versions}" -- ${cur}) )
return 0
;;
i2xuninstall)
local versions="$(u3d list | sed 's/^Version \([0-9\\.abfp]*\).*$/\1/')"
COMPREPLY=( $(compgen -W "${versions}" -- ${cur}) )
return 0
;;
esac
}
complete -F _u3d u3d
installation may be os-dependant, I manually put it into my .bashrc
it would be great to add contextual autocompletion features to the options.
i came up with a basic bash script with some stuff (it autocomplete with commands, and with installed versions after the -u flag or uninstall command):
installation may be os-dependant, I manually put it into my .bashrc