]> jfr.im git - yt-dlp.git/blame - devscripts/bash-completion.in
[bash-completion] Complete filenames or directories if the previous option requires it
[yt-dlp.git] / devscripts / bash-completion.in
CommitLineData
3d298606 1__youtube_dl()
cc51a7d4 2{
c1f9c59d 3 local cur prev opts fileopts diropts
cc51a7d4
FV
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
c1f9c59d 6 prev="${COMP_WORDS[COMP_CWORD-1]}"
bdff3455 7 opts="{{flags}}"
9193c1ee 8 keywords=":ytfavorites :ytrecommended :ytsubscriptions :ytwatchlater"
c1f9c59d
JMF
9 fileopts="-a|--batch-file|--download-archive|--cookies"
10 diropts="--cache-dir"
11
12 if [[ ${prev} =~ ${fileopts} ]]; then
13 COMPREPLY=( $(compgen -f -- ${cur}) )
14 return 0
15 elif [[ ${prev} =~ ${diropts} ]]; then
16 COMPREPLY=( $(compgen -d -- ${cur}) )
17 return 0
18 fi
cc51a7d4 19
9193c1ee
JMF
20 if [[ ${cur} =~ : ]]; then
21 COMPREPLY=( $(compgen -W "${keywords}" -- ${cur}) )
22 return 0
23 elif [[ ${cur} == * ]] ; then
cc51a7d4
FV
24 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
25 return 0
26 fi
27}
28
3d298606 29complete -F __youtube_dl youtube-dl