bash-completion.in 832 B

1234567891011121314151617181920212223242526272829
  1. __yt_dlp()
  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 __yt_dlp yt-dlp