Skip to content

Instantly share code, notes, and snippets.

@nlimpid
Created June 4, 2019 05:32
Show Gist options
  • Save nlimpid/225d8022c8a9c10915cc7c486a758109 to your computer and use it in GitHub Desktop.
Save nlimpid/225d8022c8a9c10915cc7c486a758109 to your computer and use it in GitHub Desktop.
bash complete
_foo()
{
local cur prev
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ${COMP_CWORD} in
1)
COMPREPLY=($(compgen -W "configure show" -- ${cur}))
;;
2)
case ${prev} in
configure)
COMPREPLY=($(compgen -W "CM DSP NPU" -- ${cur}))
;;
show)
COMPREPLY=($(compgen -W "some other args" -- ${cur}))
;;
esac
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _foo foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment