# bash completion for cdrecord/wodim -*- shell-script -*- proc _cdrecord { local cur prev words cword _init_completion -n = || return local i generic_options track_options track_mode # foo=bar style option if [[ "$cur" == *=* ]] { setglobal prev = $(cur%%=*) setglobal cur = $(cur#*=) match $prev { with textfile|cuefile|msifile _filedir with blank setglobal COMPREPLY = ''( $( compgen -W 'help all fast track unreserve trtail unclose session' -- "$cur" ) ) with driveropts if [[ $cur == *=* ]] { setglobal prev = $(cur%%=*) setglobal cur = $(cur#*=) match $prev { with varirec setglobal COMPREPLY = ''( $( compgen -W "-2 -1 0 1 2" \ -- "$cur" ) ) with gigarec setglobal COMPREPLY = ''( $( compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 1.4" -- "$cur" ) ) with tattoofile _filedir } } else { setglobal COMPREPLY = ''( $( compgen -W 'burnfree noburnfree varirec= gigarec= audiomaster forcespeed noforcespeed speedread nospeedread singlesession nosinglesession hidecdr nohidecdr tattooinfo tattoofile=' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } with driver setglobal COMPREPLY = ''( $( compgen -W "$( $1 driver=help 2>&1 | \ awk 'NR > 1 { print $1 }' ) help" -- "$cur" ) ) with minbuf setglobal COMPREPLY = ''( $( compgen -W '{25..95}' -- "$cur" ) ) } return 0 } setglobal generic_options = ''( -version -v -V -d -silent -force -immed -dummy -clone \ -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip \ -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive \ -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize \ -useinfo -packet -noclose -text debug= kdebug= minbuf= msifile= \ speed= blank= fs= ts= dev= gracetime= timeout= driver= driveropts= \ defpregap= pktsize= mcn= textfile= cuefile= ) setglobal track_options = ''( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \ -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp \ -copy -nocopy -scms isrc= index= padsize= pregap= tsize= ) # look if previous was either a file or a track option setglobal track_mode = '0' if [[ $cword -gt 1 ]] { if [[ -f $prev ]] { setglobal track_mode = '1' } else { for (( i=0; i < ${#track_options[@]}; i++ )); do if [[ "${track_options[i]}" == "$prev" ]]; then track_mode=1 break fi done } } # files are always eligible completion _filedir # track options are always available setglobal COMPREPLY = ''( $( compgen -W '${track_options[@]}' -- "$cur" ) ) # general options are no more available after file or track option if [[ $track_mode -eq 0 ]] { setglobal COMPREPLY = ''( $( compgen -W '${generic_options[@]}' -- "$cur" ) ) } [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _cdrecord cdrecord wodim # ex: ts=4 sw=4 et filetype=sh