.wg-docker_bash-completion 680 B

12345678910111213141516171819202122232425262728
  1. #/usr/bin/env bash
  2. WG_DOCKER_PROFILE_PATH="/opt/wg-docker/profiles"
  3. _wg-docker_completions()
  4. {
  5. local cur prev opts
  6. COMPREPLY=()
  7. cur="${COMP_WORDS[COMP_CWORD]}"
  8. prev="${COMP_WORDS[COMP_CWORD-1]}"
  9. opts="firefox shell thunderbird up"
  10. if [[ ${cur} == * ]] ; then
  11. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  12. local sub_opts="$(ls $WG_DOCKER_PROFILE_PATH)"
  13. case "$prev" in
  14. firefox|shell|thunderbird|up)
  15. COMPREPLY=( $(compgen -W "${sub_opts}" -- ${cur}) )
  16. return 0
  17. ;;
  18. version)
  19. esac
  20. fi
  21. }
  22. complete -F _wg-docker_completions wg-docker