Create a bash-completion for youtube-dl #134

Closed
opened 2026-02-20 22:26:13 -05:00 by deekerman · 4 comments
Owner

Originally created by @phihag on GitHub (Oct 12, 2011).

As the number of options is growing, contributing a bash completion would be a nice idea.

Originally created by @phihag on GitHub (Oct 12, 2011). As the number of options is growing, contributing a bash completion would be a nice idea.
Author
Owner

@MK3IcebergSlim commented on GitHub (Oct 12, 2011):

Forgive my ignorance, could you explain the bash completion. I know if I don't know what you are talking about I shouldn't worry about it but I'm just curious.

@MK3IcebergSlim commented on GitHub (Oct 12, 2011): Forgive my ignorance, could you explain the bash completion. I know if I don't know what you are talking about I shouldn't worry about it but I'm just curious.
Author
Owner

@phihag commented on GitHub (Oct 12, 2011):

@MK3IcebergSlim Basically, bash (or any other shell) completion allows you to enter youtube-dl in the shell and hit the Tab key to list all possible options. For example, if you enter ls -- in bash and press Tab twice, it displays something like:

$ ls --
--all         --file-type       --quote-name
--almost-all  --format=         --quoting-style=

This is just a short reminder for myself (or anyone interested) to implement the necessary script to be able to do the same with youtube-dl. Since I'm currently working on too many projects at once, it might take some time until I get to this low-priority feature.

For details, refer to the wikipedia article.

@phihag commented on GitHub (Oct 12, 2011): @MK3IcebergSlim Basically, bash (or any other shell) completion allows you to enter `youtube-dl` in the shell and hit the `Tab` key to list all possible options. For example, if you enter `ls --` in bash and press `Tab` twice, it displays something like: ``` $ ls -- --all --file-type --quote-name --almost-all --format= --quoting-style= ``` This is just a short reminder for myself (or anyone interested) to implement the necessary script to be able to do the same with youtube-dl. Since I'm currently working on too many projects at once, it might take some time until I get to this low-priority feature. For details, refer to the [wikipedia article](http://en.wikipedia.org/wiki/Command-line_completion).
Author
Owner

@MK3IcebergSlim commented on GitHub (Oct 12, 2011):

Gotcha

@MK3IcebergSlim commented on GitHub (Oct 12, 2011): Gotcha
Author
Owner

@them0nk commented on GitHub (May 12, 2012):

I wrote a very simple bash autocomplete function for my ubuntu and placed it in my .bashrc file.

__youtube-dl()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    opts="-h --help --version -U --update -i --ignore-errors -r --rate-limit -R --retries --dump-user-agent --list-extractors --playlist-start --playlist-end --match-title --reject-title --max-downloads -t --title -l --literal -A --auto-number -o --output -a --batch-file -w --no-overwrites -c --continue --no-continue --cookies --no-part --no-mtime --write-description --write-info-json -q --quiet -s --simulate --skip-download -g --get-url -e --get-title --get-thumbnail --get-description --get-filename --get-format --no-progress --console-title -v --verbose -f --format --all-formats --prefer-free-formats --max-quality -F --list-formats --write-srt --srt-lang -u --username -p --password -n --netrc --extract-audio --audio-format --audio-quality -k --keep-video"

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

complete -F __youtube-dl youtube-dl
@them0nk commented on GitHub (May 12, 2012): I wrote a very simple bash autocomplete function for my ubuntu and placed it in my .bashrc file. ``` __youtube-dl() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" opts="-h --help --version -U --update -i --ignore-errors -r --rate-limit -R --retries --dump-user-agent --list-extractors --playlist-start --playlist-end --match-title --reject-title --max-downloads -t --title -l --literal -A --auto-number -o --output -a --batch-file -w --no-overwrites -c --continue --no-continue --cookies --no-part --no-mtime --write-description --write-info-json -q --quiet -s --simulate --skip-download -g --get-url -e --get-title --get-thumbnail --get-description --get-filename --get-format --no-progress --console-title -v --verbose -f --format --all-formats --prefer-free-formats --max-quality -F --list-formats --write-srt --srt-lang -u --username -p --password -n --netrc --extract-audio --audio-format --audio-quality -k --keep-video" if [[ ${cur} == * ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 fi } complete -F __youtube-dl youtube-dl ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#134
No description provided.