| 1 |
_dotenv() |
| 2 |
{ |
| 3 |
local cur prev words cword |
| 4 |
_init_completion || return |
| 5 |
|
| 6 |
# find completion(s) for command executed with dotenv |
| 7 |
local i |
| 8 |
for (( i=1; i <= COMP_CWORD; i++ )); do |
| 9 |
if [[ ${COMP_WORDS[i]} != -* ]]; then |
| 10 |
_command_offset $i |
| 11 |
return |
| 12 |
fi |
| 13 |
# if current option requires a parameter, ignore the next one |
| 14 |
case "${COMP_WORDS[i]}" in |
| 15 |
-e|--dotenv) |
| 16 |
((i++)) |
| 17 |
;; |
| 18 |
esac |
| 19 |
done |
| 20 |
|
| 21 |
# completion for dotenv files |
| 22 |
case "$prev" in |
| 23 |
-e|--dotenv) |
| 24 |
COMPREPLY=( $( compgen -f -- "$cur" ) ) |
| 25 |
return |
| 26 |
;; |
| 27 |
esac |
| 28 |
|
| 29 |
# check dotenv's options |
| 30 |
if [[ $cur == -* ]]; then |
| 31 |
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) |
| 32 |
return |
| 33 |
fi |
| 34 |
|
| 35 |
} && |
| 36 |
complete -F _dotenv dotenv |
| 37 |
|
| 38 |
# vim: filetype=sh |