On Sat, May 24, 2014 at 07:42:55PM +0200, Alessandro Ghedini wrote: > On sab, mag 24, 2014 at 11:07:00 +0200, Moritz Muehlenhoff wrote: > > Package: bash-completion > > Severity: wishlist > > Tags: patch > > > > Hi, > > please add support for mpv (it's a fork of mplayer). Patch attached. > > Here's some nitpick:
Thanks, an updated version is attached (based on your comments and geared towards the mpv version in experimental. > In any case I don't use bash, so I can't say if it works correctly or not. I'm using the mpv completion for some weeks and it works well for me. Cheers, Moritz
# 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 -audio-file) _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ac3|ape)' return 0 ;; -sub-file) _filedir '@(srt|sub|txt|utf|rar|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