PageRenderTime 76ms CodeModel.GetById 73ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion_lib/complete -o filenames/cdrecord

http://github.com/brinkman83/bashrc
#! | 79 lines | 69 code | 10 blank | 0 comment | 0 complexity | e4222b65be669dd3c842656331c237b5 MD5 | raw file
 1# cdrecord(1) completion
 2
 3
 4comp_include _filedir _get_cword
 5
 6
 7_cdrecord()
 8{
 9    local cur prev i generic_options track_options track_mode
10
11    COMPREPLY=()
12    cur=`_get_cword`
13    prev=${COMP_WORDS[COMP_CWORD-1]}
14
15    # foo=bar style option
16    if [[ "$cur" == *=* ]]; then
17        prev=${cur/=*/}
18        cur=${cur/*=/}
19        case "$prev" in
20            @(text|cue)file)
21                _filedir
22                return 0
23                ;;
24            blank)
25                COMPREPLY=( $( compgen -W 'help all fast \
26                track unreserve trtail unclose session' \
27                -- $cur ) )
28                return 0
29                ;;
30            driveropts)
31                COMPREPLY=( $( compgen -W 'burnfree noburnfree\
32                  varirec= audiomaster forcespeed noforcespeed\
33                  speedread nospeedread singlesession \
34                  nosinglesession hidecdr nohidecdr tattooinfo\
35                  tattoofile=' -- $cur ) )
36                return 0
37                ;;
38        esac
39    fi
40
41    generic_options=(-version -v -V -d -silent -s -force -immed -dummy \
42             -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \
43             -atip -fix -nofix -waiti -load -lock -eject -format \
44             -setdropts -checkdrive -prcap -inq -scanbus -reset \
45             -abort -overburn -ignsize -useinfo -packet -noclose \
46             -text debug= kdebug= kd= minbuf= speed= blank= fs= \
47             dev= gracetime= timeout= driver= driveropts= \
48             defpregap= pktsize= mcn= textfile= cuefile=)
49    track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
50               -isosize -pad padsize= -nopad -shorttrack -noshorttrack\
51               pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= \
52               isrc= index=)
53    # look if previous was either a file or a track option
54    track_mode=0
55    if [ $COMP_CWORD -gt 1 ]; then
56        if [ -f "$prev" ]; then
57            track_mode=1
58        else
59            for (( i=0; i < ${#track_options[@]}; i++ )); do
60                if [[ "${track_options[i]}" == "$prev" ]]; then
61                    track_mode=1
62                    break
63                fi
64            done
65        fi
66    fi
67
68    # files are always eligible completion
69    _filedir
70    # track options are always available
71    COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '${track_options[@]}' -- $cur ) )
72    # general options are no more available after file or track option
73    if [ $track_mode -eq 0 ]; then
74        COMPREPLY=( ${COMPREPLY[@]} \
75                $( compgen -W '${generic_options[@]}' -- $cur ) )
76    fi
77} # _cdrecord()
78
79