diff --git a/etc/bash-completion.d/ros b/etc/bash-completion.d/ros index 5ba0041..c7b623c 100755 --- a/etc/bash-completion.d/ros +++ b/etc/bash-completion.d/ros @@ -11,11 +11,45 @@ _ros() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="--help --verbose --version" - if [[ ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi + opts="--help -w --wrap -m --image -L --lisp -l --load -S + --source-registry --load-system -p --package -sp --system-package -e + --eval --require -q --quit -r --restart -E --entry -i --init -ip + --print -iw --write -F --final -R --rc +R --no-rc -Q --quicklisp +Q + --no-quicklisp -v --verbose --quiet --test" + + subcommands="install config setup version help run wait use list init emacs dump delete build" + subcommands_caserule=$(echo $subcommands | sed 's/ /|/g') + case $prev in + # initially thought emacs has some default shell complete, but it turned out it doesnt + # therefore the default completion suffices + # emacs) + # # in /usr/share/bash-completion/bash_completion + # _command_offset $((COMP_CWORD-1)) + # ;; + setup|version|init|run|emacs|wait) + # these commands provide only the default completion + # it takes no arguments and it does some real jobs + # or there are no meaningful subsubcommands + return 124 + # default completion + ;; + build) + # complete filenames + COMPREPLY=( $(compgen -A file -o filenames -- ${cur}) ) ;; + install|config|help|use|list|dump|delete) + # espects these commands output completion candidates to the stdout + COMPREPLY=( $(compgen -W "$(ros $prev 2> /dev/null)" -- ${cur}) ) ;; + *) + if [[ $cur == [+-]* ]] + then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + else + COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) ) + fi + ;; + esac + return 0 } + complete -F _ros ros