2013-10-18 14:13:46 -07:00
|
|
|
__youtube_dl()
|
2012-11-29 07:51:55 -08:00
|
|
|
{
|
2013-11-26 15:42:59 -08:00
|
|
|
local cur prev opts fileopts diropts keywords
|
2012-11-29 07:51:55 -08:00
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
2013-11-26 15:41:30 -08:00
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
2012-12-07 12:38:45 -08:00
|
|
|
opts="{{flags}}"
|
2013-11-26 15:42:59 -08:00
|
|
|
keywords=":ytfavorites :ytrecommended :ytsubscriptions :ytwatchlater :ythistory"
|
2013-11-26 15:41:30 -08:00
|
|
|
fileopts="-a|--batch-file|--download-archive|--cookies"
|
|
|
|
diropts="--cache-dir"
|
|
|
|
|
|
|
|
if [[ ${prev} =~ ${fileopts} ]]; then
|
|
|
|
COMPREPLY=( $(compgen -f -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
elif [[ ${prev} =~ ${diropts} ]]; then
|
|
|
|
COMPREPLY=( $(compgen -d -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
fi
|
2012-11-29 07:51:55 -08:00
|
|
|
|
2013-08-30 11:11:53 -07:00
|
|
|
if [[ ${cur} =~ : ]]; then
|
|
|
|
COMPREPLY=( $(compgen -W "${keywords}" -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
elif [[ ${cur} == * ]] ; then
|
2012-11-29 07:51:55 -08:00
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-10-18 14:13:46 -07:00
|
|
|
complete -F __youtube_dl youtube-dl
|