Last active
December 17, 2015 13:49
-
-
Save timyates/5619924 to your computer and use it in GitHub Desktop.
Quick and dirty GVM bash autocompletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_gvm_complete() | |
{ | |
local CANDIDATES | |
COMPREPLY=() | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=( $(compgen -W "install uninstall rm list use current version default selfupdate broadcast offline help flush" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
elif [ $COMP_CWORD -eq 2 ]; then | |
case "${COMP_WORDS[COMP_CWORD-1]}" in | |
"install" | "uninstall" | "rm" | "list" | "use" | "current" ) | |
CANDIDATES=$(curl -s "${GVM_SERVICE}/candidates" | tr ',' ' ') | |
COMPREPLY=( $(compgen -W "$CANDIDATES" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
;; | |
"offline" ) | |
COMPREPLY=( $(compgen -W "enable disable" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
;; | |
"flush" ) | |
COMPREPLY=( $(compgen -W "candidates broadcast archives temp" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
;; | |
*) | |
;; | |
esac | |
elif [ $COMP_CWORD -eq 3 ]; then | |
case "${COMP_WORDS[COMP_CWORD-2]}" in | |
"install" | "uninstall" | "rm" | "use" | "default" ) | |
COMPREPLY=( $(compgen -W "$(curl -s "${GVM_SERVICE}/candidates/${COMP_WORDS[COMP_CWORD-1]}" | tr ',' ' ')" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
;; | |
*) | |
;; | |
esac | |
fi | |
return 0 | |
} | |
complete -F _gvm_complete gvm |
Whoops! Done!
Added flush (gvm 1.3.0)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget the offline command ;-)