File: bash-completion.in

package info (click to toggle)
yt-dlp 2026.02.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,724 kB
  • sloc: python: 221,100; javascript: 865; makefile: 220; sh: 89
file content (33 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
__yt_dlp()
{
    local cur prev opts fileopts diropts keywords
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="{{flags}}"
    keywords=":ytfavorites :ytrecommended :ytsubscriptions :ytwatchlater :ythistory"
    fileopts="-a|--batch-file|--download-archive|--cookies|--load-info-json"
    diropts="--cache-dir"

    if [[ ${prev} =~ ${fileopts} ]]; then
        local IFS=$'\n'
        type compopt &>/dev/null && compopt -o filenames
        COMPREPLY=( $(compgen -f -- ${cur}) )
        return 0
    elif [[ ${prev} =~ ${diropts} ]]; then
        local IFS=$'\n'
        type compopt &>/dev/null && compopt -o dirnames
        COMPREPLY=( $(compgen -d -- ${cur}) )
        return 0
    fi

    if [[ ${cur} =~ : ]]; then
        COMPREPLY=( $(compgen -W "${keywords}" -- ${cur}) )
        return 0
    elif [[ ${cur} == * ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
}

complete -F __yt_dlp yt-dlp