bash-completion.in 844 B

123456789101112131415161718192021222324252627282930
  1. __youtube_dl()
  2. {
  3. local cur prev opts fileopts diropts keywords
  4. COMPREPLY=()
  5. cur="${COMP_WORDS[COMP_CWORD]}"
  6. prev="${COMP_WORDS[COMP_CWORD-1]}"
  7. opts="{{flags}}"
  8. keywords=":ytfavorites :ytrecommended :ytsubscriptions :ytwatchlater :ythistory"
  9. fileopts="-a|--batch-file|--download-archive|--cookies|--load-info"
  10. diropts="--cache-dir"
  11. if [[ ${prev} =~ ${fileopts} ]]; then
  12. COMPREPLY=( $(compgen -f -- ${cur}) )
  13. return 0
  14. elif [[ ${prev} =~ ${diropts} ]]; then
  15. COMPREPLY=( $(compgen -d -- ${cur}) )
  16. return 0
  17. fi
  18. if [[ ${cur} =~ : ]]; then
  19. COMPREPLY=( $(compgen -W "${keywords}" -- ${cur}) )
  20. return 0
  21. elif [[ ${cur} == * ]] ; then
  22. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  23. return 0
  24. fi
  25. }
  26. complete -F __youtube_dl youtube-dl