PageRenderTime 86ms CodeModel.GetById 83ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion.d/mplayer

http://github.com/brinkman83/bashrc
#! | 242 lines | 234 code | 8 blank | 0 comment | 0 complexity | 8772538b950fc3f579763a3567b13515 MD5 | raw file
  1# mplayer(1) completion
  2
  3have mplayer && {
  4_mplayer_options_list()
  5{
  6    cur=${cur%\\}
  7    COMPREPLY=( $( compgen -W "$( $1 $2 help 2>/dev/null | \
  8        sed -e '1,/^Available/d' | awk '{print $1}' | \
  9        sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) )
 10}
 11
 12_mplayer()
 13{
 14    local cmd cur prev skinsdir IFS=$' \t\n' i j k=0
 15
 16    COMPREPLY=()
 17    cmd=${COMP_WORDS[0]}
 18    cur=`_get_cword`
 19    prev=${COMP_WORDS[COMP_CWORD-1]}
 20
 21    case "$prev" in
 22        -@([av][cfo]|[av]fm|vop|fstype|demuxer|o[av]c|of|profile))
 23            _mplayer_options_list $cmd $prev
 24            return 0
 25            ;;
 26        -audiofile)
 27            _filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|w?(a)v|W?(A)V|mid|MID|flac|FLAC|mka|MKA|ape|APE)'
 28            return 0
 29            ;;
 30        -font)
 31            _filedir '@(desc|ttf)'
 32            return 0
 33            ;;
 34        -sub)
 35            _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|ass|ASS)'
 36            return 0
 37            ;;
 38        -vobsub)
 39            _filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
 40            IFS=$'\t\n'
 41            COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
 42                        if [ -f $i -a -r $i ]; then
 43                            echo ${i%.*}
 44                        else
 45                            echo $i
 46                        fi
 47                       done ) )
 48            IFS=$' \t\n'
 49            return 0
 50            ;;
 51        -ifo)
 52            _filedir '@(ifo|IFO)'
 53            return 0
 54            ;;
 55        -cuefile)
 56            _filedir '@(bin|BIN|cue|CUE)'
 57            return 0
 58            ;;
 59        -skin)
 60            # if you don't have installed mplayer in /usr you
 61            # may want to set the MPLAYER_SKINS_DIR global variable
 62            if [ -n "$MPLAYER_SKINS_DIR" ]; then
 63                skinsdir=$MPLAYER_SKINS_DIR
 64            else
 65                skinsdir=/usr/share/mplayer/Skin
 66            fi
 67
 68            IFS=$'\t\n'
 69            for i in ~/.mplayer/Skin $skinsdir; do
 70                if [ -d $i -a -r $i ]; then
 71                    for j in $( compgen -d $i/$cur ); do
 72                        COMPREPLY[$k]=${j#$i/}
 73                        k=$((++k))
 74                    done
 75                fi
 76            done
 77            IFS=$' \t\n'
 78            return 0
 79            ;;
 80        -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
 81            cur=${cur:=/dev/}
 82            _filedir
 83            return 0
 84            ;;
 85        -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
 86        -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
 87        -passlogfile)
 88            _filedir
 89            return 0
 90            ;;
 91        -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \
 92        -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \
 93        -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \
 94        -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \
 95        -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \
 96        -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \
 97        -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
 98        -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \
 99        -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \
100        -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \
101        -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \
102        -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \
103        -sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
104            return 0
105            ;;
106        -lavdopts)
107            COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' -- "$cur" ) )
108            return 0
109            ;;
110        -lavcopts)
111            COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= \
112                mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint= \
113                vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate= \
114                vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= \
115                vi_qoffset= vqblur= vqcomp= vrc_eq= vrc_override= \
116                vrc_init_cplx= vqsquish= vlelim= vcelim= vstrict= vdpart \
117                vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask= \
118                scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= \
119                predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic \
120                umv' -- "$cur" ) )
121        return 0
122        ;;
123    -ssf)
124        COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur" ) )
125            return 0
126            ;;
127        -jpeg)
128            COMPREPLY=( $( compgen -W 'noprogressive progressive nobaseline \
129                baseline optimize= smooth= quality= outdir=' -- "$cur" ) )
130            return 0
131            ;;
132        -xvidopts)
133            COMPREPLY=( $( compgen -W 'dr2 nodr2' -- "$cur" ) )
134            return 0
135            ;;
136        -xvidencopts)
137            COMPREPLY=( $( compgen -W 'pass= bitrate= fixed_quant= me_quality= \
138                4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer= \
139                quant_range= min_key_interval= max_key_interval= mpeg_quant \
140                mod_quant lumi_mask hintedme hintfile debug keyframe_boost= \
141                kfthreshold= kfreduction=' -- "$cur" ) )
142            return 0
143            ;;
144        -divx4opts)
145            COMPREPLY=( $( compgen -W 'br= key= deinterlace q= min_quant= \
146                max_quant= rc_period= rc_reaction_period= crispness= \
147                rc_reaction_ratio= pass= vbrpass= help' -- "$cur" ) )
148            return 0
149            ;;
150        -info)
151            COMPREPLY=( $( compgen -W 'name= artist= genre= subject= \
152                copyright= srcform= comment= help' -- "$cur" ) )
153            return 0
154            ;;
155        -lameopts)
156            COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= \
157                mode= padding= fast preset= help' -- "$cur" ) )
158            return 0
159            ;;
160        -rawaudio)
161            COMPREPLY=( $( compgen -W 'on channels= rate= samplesize= format=' \
162                -- "$cur" ) )
163            return 0
164            ;;
165        -rawvideo)
166            COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= \
167                h= y420 yv12 yuy2 y8 format= size=' -- "$cur" ) )
168            return 0
169            ;;
170        -aop)
171            COMPREPLY=( $( compgen -W 'list= delay= format= fout= volume= mul= \
172                softclip' -- "$cur" ) )
173            return 0
174            ;;
175        -dxr2)
176            COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded iec958-decoded \
177                mute ucode= 75ire bw color interlaced macrovision= norm= \
178                square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot= \
179                ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r= \
180                ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor= \
181                oly-cor= overlay overlay-ratio= update-cache' -- "$cur" ))
182            return 0
183            ;;
184        -tv)
185            COMPREPLY=( $( compgen -W 'on noaudio driver= device= input= freq= \
186                outfmt= width= height= buffersize= norm= channel= chanlist= \
187                audiorate= forceaudio alsa amode= forcechan= adevice= audioid= \
188                volume= bass= treble= balance= fps= channels= immediatemode=' \
189                -- "$cur" ) )
190            return 0
191            ;;
192        -mf)
193            COMPREPLY=( $( compgen -W 'on w= h= fps= type=' -- "$cur" ) )
194            return 0
195            ;;
196        -cdda)
197            COMPREPLY=( $( compgen -W 'speed= paranoia= generic-dev= \
198                sector-size= overlap= toc-bias toc-offset= skip noskip' \ 
199                -- "$cur" ) )
200            return 0
201            ;;
202        -input)
203            COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate keylist cmdlist \
204                js-dev file' -- "$cur" ) )
205            return 0
206            ;;
207        -af)
208            COMPREPLY=( $( compgen -W 'resample resample= channels channels= \
209                format format= volume volume= delay delay= pan pan= sub sub= \
210                surround surround=' -- "$cur" ) )
211            return 0
212            ;;
213        -af-adv)
214            COMPREPLY=( $( compgen -W 'force= list=' -- "$cur" ) )
215            return 0
216            ;;
217    esac
218
219    case "$cur" in
220        -*)
221            COMPREPLY=( $( compgen -W '$( $cmd -list-options 2>/dev/null | \
222                sed -ne '1,/^[[:space:]]*Name/d' \
223                    -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \
224                    -e "/^-\(Total\|.*\*\)\?$/!p" )' -- "$cur" ) )
225            ;;
226        *)
227            _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]|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|ts|TS|3g[p2]|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2ts|M2TS|vdr|VDR|xvid|XVID|ape|APE)'
228            ;;
229    esac
230
231    return 0
232}
233complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
234}
235
236# Local variables:
237# mode: shell-script
238# sh-basic-offset: 4
239# sh-indent-comment: t
240# indent-tabs-mode: nil
241# End:
242# ex: ts=4 sw=4 et filetype=sh