# bash completion for smartctl(8) -*- shell-script -*- proc _smartctl_quietmode { setvar COMPREPLY = ''( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) ) } proc _smartctl_device { case (cur) { areca*|3ware*|megaraid*|cciss* { setvar COMPREPLY = ''( ${cur%%,*},{0..31} ) setvar COMPREPLY = ''( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) } hpt* { setvar COMPREPLY = ''( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} ) setvar COMPREPLY = ''( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) ) } * { setvar COMPREPLY = ''( $( compgen -W "ata scsi sat usbcypress usbjmicron usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \ -- "$cur" ) ) case{ areca|3ware|hpt|megaraid|cciss { compopt -o nospace } } } } } proc _smartctl_tolerance { setvar COMPREPLY = ''( $( compgen -W 'normal conservative permissive verypermissive' \ -- "$cur" ) ) } proc _smartctl_badsum { setvar COMPREPLY = ''( $( compgen -W 'warn exit ignore' -- "$cur" ) ) } proc _smartctl_report { setvar COMPREPLY = ''( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) ) } proc _smartctl_powermode { setvar COMPREPLY = ''( $( compgen -W 'never sleep standby idle' -- "$cur" ) ) } proc _smartctl_feature { setvar COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) } proc _smartctl_log { setvar 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 { setvar 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 { setvar COMPREPLY = ''( $( compgen -W 'none samsung samsung2 samsung3 swapid' \ -- "$cur" ) ) } proc _smartctl_presets { setvar COMPREPLY = ''( $( compgen -W 'use ignore show showall' -- "$cur" ) ) } proc _smartctl_test { [[ $cur == @(pending|scttempint|vendor), ]] && return 0 setvar 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 == +* ]] { setvar prefix = '+' setvar cur = "${cur#+}" } _filedir h [[ -n $prefix ]] && setvar COMPREPLY = ''( "${COMPREPLY[@]/#/$prefix}" ) } proc _smartctl { local cur prev words cword split _init_completion -s || return case (prev) { -q|--quietmode { _smartctl_quietmode } -d|--device { _smartctl_device return 0 } -T|--tolerance { _smartctl_tolerance return 0 } -b|--badsum { _smartctl_badsum return 0 } -r|--report { _smartctl_report return 0 } -n|--nocheck { _smartctl_powermode return 0 } -s|--smart|-o|--offlineauto|-S|--saveauto { _smartctl_feature return 0 } -l|--log { _smartctl_log return 0 } -v|--vendorattribute { _smartctl_vendorattribute return 0 } -F|--firmwarebug { _smartctl_firmwarebug return 0 } -P|--presets { _smartctl_presets return 0 } -B|--drivedb { _smartctl_drivedb return 0 } -t|--test { _smartctl_test return 0 } } $split && return 0 if [[ "$cur" == -* ]] { setvar 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 { setvar cur = ${cur:=/dev/} _filedir } } && complete -F _smartctl smartctl # ex: ts=4 sw=4 et filetype=sh