97 lines
3.5 KiB
Plaintext
Raw Normal View History

2009-05-17 22:14:02 +02:00
# bash completion for cdrecord/wodim
2010-10-23 12:31:44 +03:00
# We set -o nospace and turn it off in several places for bash < 4
# reasons; assuming bash >= 4 we could instead not turn it on
# initially but only in the few cases where it's actually needed.
2009-06-08 21:22:43 +03:00
have cdrecord || have wodim &&
2009-05-17 22:14:02 +02:00
_cdrecord()
{
local cur prev i generic_options track_options track_mode
2009-05-17 22:14:02 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=()
2010-10-23 12:31:44 +03:00
_get_comp_words_by_ref -n = cur prev
2009-05-17 22:14:02 +02:00
# foo=bar style option
if [[ "$cur" == *=* ]]; then
2010-10-23 12:31:44 +03:00
prev=${cur%%=*}
cur=${cur#*=}
case $prev in
textfile|cuefile)
2010-10-23 12:31:44 +03:00
compopt +o nospace &>/dev/null
_filedir
;;
blank)
2010-10-23 12:31:44 +03:00
compopt +o nospace &>/dev/null
2010-10-23 11:22:18 +03:00
COMPREPLY=( $( compgen -W 'help all fast track unreserve trtail
unclose session' -- "$cur" ) )
;;
driveropts)
2010-10-23 12:31:44 +03:00
compopt +o nospace &>/dev/null
2010-10-23 11:22:18 +03:00
COMPREPLY=( $( compgen -W 'burnfree noburnfree varirec=
gigarec= audiomaster forcespeed noforcespeed speedread
nospeedread singlesession nosinglesession hidecdr nohidecdr
tattooinfo tattoofile=' -- "$cur" ) )
;;
2010-10-23 12:36:13 +03:00
driver)
compopt +o nospace &>/dev/null
COMPREPLY=( $( compgen -W "$( $1 driver=help 2>&1 | \
awk 'NR > 1 { print $1 }' ) help" -- "$cur" ) )
;;
2010-10-23 12:48:53 +03:00
minbuf)
compopt +o nospace &>/dev/null
COMPREPLY=( $( compgen -W "$( seq 25 95 2>/dev/null )" \
-- "$cur" ) )
;;
esac
2010-10-23 12:31:44 +03:00
return 0
fi
2009-05-17 22:14:02 +02:00
2010-10-23 12:43:54 +03:00
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= )
2010-10-23 11:22:18 +03:00
track_options=( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
2010-10-23 12:43:54 +03:00
-isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp \
-copy -nocopy -scms isrc= index= padsize= pregap= tsize= )
2009-10-04 19:42:50 +02:00
# look if previous was either a file or a track option
track_mode=0
if [ $COMP_CWORD -gt 1 ]; then
if [ -f "$prev" ]; then
track_mode=1
else
for (( i=0; i < ${#track_options[@]}; i++ )); do
if [[ "${track_options[i]}" == "$prev" ]]; then
track_mode=1
break
fi
done
fi
fi
2009-05-17 22:14:02 +02:00
2009-10-04 19:42:50 +02:00
# files are always eligible completion
_filedir
# track options are always available
COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W '${track_options[@]}' -- "$cur" ) )
# general options are no more available after file or track option
if [ $track_mode -eq 0 ]; then
COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W '${generic_options[@]}' -- "$cur" ) )
fi
2010-10-23 12:31:44 +03:00
[[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \
compopt +o nospace &>/dev/null
2009-05-17 22:14:02 +02:00
} &&
2010-10-23 12:31:44 +03:00
complete -F _cdrecord -o nospace cdrecord wodim
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh