summaryrefslogtreecommitdiff
path: root/completions/smartctl
diff options
context:
space:
mode:
Diffstat (limited to 'completions/smartctl')
-rw-r--r--completions/smartctl86
1 files changed, 54 insertions, 32 deletions
diff --git a/completions/smartctl b/completions/smartctl
index 74e42816..8461c988 100644
--- a/completions/smartctl
+++ b/completions/smartctl
@@ -1,18 +1,31 @@
-# bash completion for smartctl(8)
+# bash completion for smartctl(8) -*- shell-script -*-
-have smartctl &&
-{
_smartctl_quietmode()
{
COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) )
}
_smartctl_device()
{
- local i opts='ata scsi sat marvell hpt cciss'
- for (( i=0; i <= 31; i++ )) ; do
- opts="$opts 3ware,$i"
- done
- COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+ case $cur in
+ areca*|3ware*|megaraid*|cciss*)
+ COMPREPLY+=( ${cur%%,*},{0..31} )
+ COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
+ ;;
+ hpt*)
+ COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} )
+ 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
+ ;;
+ esac
+ ;;
+ esac
}
_smartctl_tolerance()
{
@@ -37,7 +50,9 @@ _smartctl_feature()
}
_smartctl_log()
{
- COMPREPLY=( $( compgen -W 'error selftest selective directory' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'error selftest selective directory background
+ sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
+ scttemphist scterc gplog smartlog xerror xselftest' -- "$cur" ) )
}
_smartctl_vendorattribute()
{
@@ -57,19 +72,27 @@ _smartctl_presets()
}
_smartctl_test()
{
- COMPREPLY=( $( compgen -W 'offline short long conveyance select \
- afterselect,on afterselect,off pending scttempint' -- "$cur" ) )
+ [[ $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
+}
+_smartctl_drivedb()
+{
+ local prefix=
+ if [[ $cur == +* ]] ; then
+ prefix=+
+ cur="${cur#+}"
+ fi
+ _filedir h
+ [[ -n $prefix ]] && COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" )
}
-
_smartctl()
{
- local cur prev split=false
-
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
-
- _split_longopt && split=true
+ local cur prev words cword split
+ _init_completion -s || return
case $prev in
-q|--quietmode)
@@ -79,7 +102,7 @@ _smartctl()
_smartctl_device
return 0
;;
- -t|--tolerance)
+ -T|--tolerance)
_smartctl_tolerance
return 0
;;
@@ -115,6 +138,10 @@ _smartctl()
_smartctl_presets
return 0
;;
+ -B|--drivedb)
+ _smartctl_drivedb
+ return 0
+ ;;
-t|--test)
_smartctl_test
return 0
@@ -124,23 +151,18 @@ _smartctl()
$split && return 0
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '--help --version --info --all --quietmode \
- --device --tolerance --badsum --report --nocheck --smart \
- --offlineauto --saveauto --health --capabilities --attributes \
- --log --vendorattribute --firmwarebug --presets --test --captive \
- --abort' -- "$cur" ) )
+ 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
cur=${cur:=/dev/}
_filedir
fi
-}
+} &&
complete -F _smartctl smartctl
-}
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh