You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
832 B

  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"
  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