# bash completion for smartctl(8) -*- shell-script -*- proc _smartctl_quietmode { setglobal COMPREPLY = ''( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) ) } proc _smartctl_device { match $cur { with areca*|3ware*|megaraid*|cciss* setglobal COMPREPLY = ''( ${cur%%,*},{0..31} ) setglobal COMPREPLY = ''( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) with hpt* setglobal COMPREPLY = ''( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} ) setglobal COMPREPLY = ''( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) with * setglobal COMPREPLY = ''( $( compgen -W "ata scsi sat usbcypress usbjmicron usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \ -- "$cur" ) ) match $(COMPREPLY[@]) { with areca|3ware|hpt|megaraid|cciss compopt -o nospace } } } proc _smartctl_tolerance { setglobal COMPREPLY = ''( $( compgen -W 'normal conservative permissive verypermissive' \ -- "$cur" ) ) } proc _smartctl_badsum { setglobal COMPREPLY = ''( $( compgen -W 'warn exit ignore' -- "$cur" ) ) } proc _smartctl_report { setglobal COMPREPLY = ''( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) ) } proc _smartctl_powermode { setglobal COMPREPLY = ''( $( compgen -W 'never sleep standby idle' -- "$cur" ) ) } proc _smartctl_feature { setglobal COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) } proc _smartctl_log { setglobal COMPREPLY = ''( $( compgen -W 'error selftest selective directory background sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts scttemphist scterc gplog smartlog xerror xselftest' -- "$cur" ) ) } proc _smartctl_vendorattribute { setglobal COMPREPLY = ''( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp 192,emergencyretractcyclect 193,loadunload 194,10xCelsius 194,unknown 198,offlinescanuncsectorct 200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" ) ) } proc _smartctl_firmwarebug { setglobal COMPREPLY = ''( $( compgen -W 'none samsung samsung2 samsung3 swapid' \ -- "$cur" ) ) } proc _smartctl_presets { setglobal COMPREPLY = ''( $( compgen -W 'use ignore show showall' -- "$cur" ) ) } proc _smartctl_test { [[ $cur == @(pending|scttempint|vendor), ]] && return 0 setglobal COMPREPLY = ''( $( compgen -W 'offline short long conveyance select, select,redo select,next afterselect,on afterselect,off pending, scttempint, vendor,' -- "$cur" ) ) [[ $COMPREPLY == *, ]] && compopt -o nospace } proc _smartctl_drivedb { local prefix= if [[ $cur == +* ]] { setglobal prefix = '+' setglobal cur = $(cur#+) } _filedir h [[ -n $prefix ]] && setglobal COMPREPLY = ''( "${COMPREPLY[@]/#/$prefix}" ) } proc _smartctl { local cur prev words cword split _init_completion -s || return match $prev { with -q|--quietmode _smartctl_quietmode with -d|--device _smartctl_device return 0 with -T|--tolerance _smartctl_tolerance return 0 with -b|--badsum _smartctl_badsum return 0 with -r|--report _smartctl_report return 0 with -n|--nocheck _smartctl_powermode return 0 with -s|--smart|-o|--offlineauto|-S|--saveauto _smartctl_feature return 0 with -l|--log _smartctl_log return 0 with -v|--vendorattribute _smartctl_vendorattribute return 0 with -F|--firmwarebug _smartctl_firmwarebug return 0 with -P|--presets _smartctl_presets return 0 with -B|--drivedb _smartctl_drivedb return 0 with -t|--test _smartctl_test return 0 } $split && return 0 if [[ "$cur" == -* ]] { setglobal COMPREPLY = ''( $( compgen -W '--help --version --info --all --xall --scan --scan-open --quietmode= --device= --tolerance= --badsum= --report= --nocheck= --smart= --offlineauto= --saveauto= --health --capabilities --attributes --log= --vendorattribute= --firmwarebug= --presets= --drivedb= --test= --captive --abort' \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } else { setglobal cur = $(cur:=/dev/) _filedir } } && complete -F _smartctl smartctl # ex: ts=4 sw=4 et filetype=sh