177 lines
4.6 KiB
Plaintext
Raw Normal View History

2009-04-18 13:31:59 +03:00
# bash completion for smartctl(8)
2009-02-04 21:23:49 +01:00
have smartctl || return
2009-02-04 21:23:49 +01:00
_smartctl_quietmode()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_device()
{
2011-02-18 22:09:05 +02:00
case $cur in
areca*|3ware*|megaraid*|cciss*)
COMPREPLY+=( ${cur%%,*},{0..31} )
2011-02-18 22:09:05 +02:00
COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
;;
hpt*)
COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} )
2011-02-18 22:09:05 +02:00
COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
;;
*)
COMPREPLY=( $( compgen -W "ata scsi sat usbcypress usbjmicron
usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \
-- "$cur" ) )
case "${COMPREPLY[@]}" in
areca|3ware|hpt|megaraid|cciss)
compopt -o nospace
2011-02-18 22:09:05 +02:00
;;
esac
;;
esac
2009-02-04 21:23:49 +01:00
}
_smartctl_tolerance()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'normal conservative permissive \
verypermissive' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_badsum()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_report()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
2009-04-18 13:16:58 +03:00
_smartctl_powermode()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) )
2009-04-18 13:16:58 +03:00
}
2009-02-04 21:23:49 +01:00
_smartctl_feature()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_log()
{
2011-02-18 22:09:05 +02:00
COMPREPLY=( $( compgen -W 'error selftest selective directory background
sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
scttemphist scterc gplog smartlog xerror xselftest' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_vendorattribute()
{
2009-10-18 21:54:54 +03:00
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" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_firmwarebug()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \
2009-10-04 19:42:50 +02:00
-- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_presets()
{
2009-10-18 21:54:54 +03:00
COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) )
2009-02-04 21:23:49 +01:00
}
_smartctl_test()
{
2011-02-18 22:09:05 +02:00
[[ $cur == @(pending|scttempint|vendor), ]] && return 0
COMPREPLY=( $( compgen -W 'offline short long conveyance select,
select,redo select,next afterselect,on afterselect,off pending,
scttempint, vendor,' -- "$cur" ) )
[[ $COMPREPLY == *, ]] && compopt -o nospace
2011-02-18 22:09:05 +02:00
}
_smartctl_drivedb()
{
local prefix=
if [[ $cur == +* ]] ; then
prefix=+
cur="${cur#+}"
fi
_filedir h
[[ -n $prefix ]] && COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" )
2009-02-04 21:23:49 +01:00
}
_smartctl()
{
local cur prev words cword split
_init_completion -s || return
2009-04-18 13:15:07 +03:00
case $prev in
2009-10-18 21:54:54 +03:00
-q|--quietmode)
_smartctl_quietmode
;;
-d|--device)
_smartctl_device
return 0
;;
-T|--tolerance)
2009-10-18 21:54:54 +03:00
_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
;;
2011-02-18 22:09:05 +02:00
-B|--drivedb)
_smartctl_drivedb
return 0
;;
2009-10-18 21:54:54 +03:00
-t|--test)
_smartctl_test
return 0
;;
esac
2009-02-04 21:23:49 +01:00
2009-10-18 21:54:54 +03:00
$split && return 0
2009-02-04 21:23:49 +01:00
2009-10-18 21:54:54 +03:00
if [[ "$cur" == -* ]]; then
2011-02-18 22:09:05 +02:00
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
2009-10-18 21:54:54 +03:00
else
cur=${cur:=/dev/}
_filedir
fi
2011-04-04 22:14:39 +03:00
} &&
2009-02-04 21:23:49 +01:00
complete -F _smartctl smartctl
# 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