[Bash-completion-devel] Bug#749115: bash-completion: Please add support for the mpv video player

Moritz Muehlenhoff jmm at inutil.org
Sat May 24 09:07:00 UTC 2014


Package: bash-completion
Severity: wishlist
Tags: patch

Hi,
please add support for mpv (it's a fork of mplayer). Patch attached.

Cheers,
        Moritz
-------------- next part --------------
# mpv(1) completion                                    -*- shell-script -*-

_mpv()
{
    local cur prev words cword
    _init_completion -n : || return

    local cmd=${words[0]} i j k=0

    case $prev in
        -audiofile)
            _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ape)'
            return 0
            ;;
        -sub)
            _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
            return 0
            ;;
        -*)
            # Assume arg is required for everything else except options
            # for which -list-options says Type is Flag or Print.
            $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null \
            | while read -r i j k; do
                if [[ $i == ${prev#-} ]]; then
                    [[ ${j,,} != @(flag|print) ]] && return 1
                    break
                fi
            done || return 0
            ;;
    esac

    case $cur in
        -*)
            COMPREPLY=( $( compgen -W '$( $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null | \
                sed -ne '1,/^[[:space:]]*Name/d' \
                    -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \
                    -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) )
            ;;
        *)
            _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|webm|WEBM|amr|AMR|awb|AWB|iso|ISO|opus|OPUS)?(.part)'
            ;;
    esac

    return 0
} &&
complete -F _mpv mpv

# ex: ts=4 sw=4 et filetype=sh


More information about the Bash-completion-devel mailing list