| 1 |
|
| 2 |
# Check for bash |
| 3 |
[ -z "$BASH_VERSION" ] && return |
| 4 |
|
| 5 |
#################################################################################################### |
| 6 |
|
| 7 |
__app() { |
| 8 |
case "${COMP_CWORD}" in |
| 9 |
1) |
| 10 |
COMPREPLY=($(compgen -W "help version list-apps launch action list-actions" -- "${COMP_WORDS[1]}")) |
| 11 |
return 0 |
| 12 |
;; |
| 13 |
|
| 14 |
2) |
| 15 |
case "${COMP_WORDS[1]}" in |
| 16 |
launch|action|list-actions) |
| 17 |
COMPREPLY=($(compgen -W "`gapplication list-apps`" -- "${COMP_WORDS[2]}")) |
| 18 |
return 0 |
| 19 |
;; |
| 20 |
|
| 21 |
*) |
| 22 |
COMPREPLY=() |
| 23 |
return 0 |
| 24 |
;; |
| 25 |
esac |
| 26 |
;; |
| 27 |
esac |
| 28 |
|
| 29 |
# Otherwise, what we will do is based on the command in ${COMP_WORDS[1]} |
| 30 |
case "${COMP_WORDS[1]}" in |
| 31 |
action) |
| 32 |
# Word 3 is the action name. This is the only one we can help with. |
| 33 |
if [ "${COMP_CWORD}" == 3 ]; then |
| 34 |
COMPREPLY=($(compgen -W "`gapplication list-actions "${COMP_WORDS[2]}"`" -- "${COMP_WORDS[3]}")) |
| 35 |
return 0 |
| 36 |
else |
| 37 |
COMPREPLY=() |
| 38 |
return 0 |
| 39 |
fi |
| 40 |
;; |
| 41 |
launch) |
| 42 |
# Filenames... |
| 43 |
COMPREPLY=($(compgen -A file "${COMP_WORDS[COMP_CWORD]}")) |
| 44 |
return 0 |
| 45 |
;; |
| 46 |
*) |
| 47 |
# Nothing else should be out this far... |
| 48 |
COMPREPLY=() |
| 49 |
return 0 |
| 50 |
esac |
| 51 |
} |
| 52 |
|
| 53 |
#################################################################################################### |
| 54 |
|
| 55 |
complete -F __app gapplication |