/bash_completion_lib/complete/smartctl

http://github.com/brinkman83/bashrc · #! · 194 lines · 182 code · 12 blank · 0 comment · 0 complexity · c46e614f836e18deac6f0756c06a51ae MD5 · raw file

  1. # smartctl(8) completion
  2. comp_include _filedir _get_cword
  3. _smartctl_quietmode()
  4. {
  5. COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
  6. }
  7. _smartctl_device()
  8. {
  9. COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
  10. }
  11. _smartctl_tolerance()
  12. {
  13. COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
  14. }
  15. _smartctl_badsum()
  16. {
  17. COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
  18. }
  19. _smartctl_report()
  20. {
  21. COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
  22. }
  23. _smartctl_feature()
  24. {
  25. COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
  26. }
  27. _smartctl_log()
  28. {
  29. COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
  30. }
  31. _smartctl_vendorattribute()
  32. {
  33. COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
  34. 9,temp 192,emergencyretractcyclect 193,loadunload \
  35. 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
  36. 200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
  37. }
  38. _smartctl_firmwarebug()
  39. {
  40. COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
  41. }
  42. _smartctl_presets()
  43. {
  44. COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
  45. }
  46. _smartctl_test()
  47. {
  48. COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
  49. }
  50. _smartctl()
  51. {
  52. local cur prev
  53. COMPREPLY=()
  54. cur=`_get_cword`
  55. prev=${COMP_WORDS[COMP_CWORD-1]}
  56. # --name value style option
  57. case "$prev" in
  58. -q)
  59. _smartctl_quietmode
  60. ;;
  61. -d)
  62. _smartctl_device
  63. return 0
  64. ;;
  65. -t)
  66. _smartctl_tolerance
  67. return 0
  68. ;;
  69. -b)
  70. _smartctl_badsum
  71. return 0
  72. ;;
  73. -r)
  74. _smartctl_report
  75. return 0
  76. ;;
  77. -s)
  78. _smartctl_feature
  79. return 0
  80. ;;
  81. -o)
  82. _smartctl_feature
  83. return 0
  84. ;;
  85. -S)
  86. _smartctl_feature
  87. return 0
  88. ;;
  89. -l)
  90. _smartctl_log
  91. return 0
  92. ;;
  93. -v)
  94. _smartctl_vendorattribute
  95. return 0
  96. ;;
  97. -F)
  98. _smartctl_firmwarebug
  99. return 0
  100. ;;
  101. -P)
  102. _smartctl_presets
  103. return 0
  104. ;;
  105. -t)
  106. _smartctl_test
  107. return 0
  108. ;;
  109. esac
  110. # --name=value style option
  111. if [[ "$cur" == *=* ]]; then
  112. prev=${cur/=*/}
  113. cur=${cur/*=/}
  114. case "$prev" in
  115. --quietmode)
  116. _smartctl_quietmode
  117. return 0
  118. ;;
  119. --device)
  120. _smartctl_device
  121. return 0
  122. ;;
  123. --tolerance)
  124. _smartctl_tolerance
  125. return 0
  126. ;;
  127. --badsum)
  128. _smartctl_badsum
  129. return 0
  130. ;;
  131. --report)
  132. _smartctl_report
  133. return 0
  134. ;;
  135. --smart)
  136. _smartctl_feature
  137. return 0
  138. ;;
  139. --offlineauto)
  140. _smartctl_feature
  141. return 0
  142. ;;
  143. --saveauto)
  144. _smartctl_feature
  145. return 0
  146. ;;
  147. --log)
  148. _smartctl_log
  149. return 0
  150. ;;
  151. --vendorattribute)
  152. _smartctl_vendorattribute
  153. return 0
  154. ;;
  155. --firmwarebug)
  156. _smartctl_firmwarebug
  157. return 0
  158. ;;
  159. --presets)
  160. _smartctl_presets
  161. return 0
  162. ;;
  163. --test)
  164. _smartctl_test
  165. return 0
  166. ;;
  167. esac
  168. fi
  169. if [[ "$cur" == -* ]]; then
  170. COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
  171. --copyright --license-i --info -a --all -q \
  172. --quietmode= -d --device= -T --tolerance= -b --badsum= \
  173. -r --report= -s --smart= -o --offlineauto= -S \
  174. --saveauto= -H --health -c --capabilities -A \
  175. --attributes -l --log= -v --vendorattribute= -F \
  176. --firmwarebug= -P --presets= -t --test= -C \
  177. --captive -X --abort' -- $cur ) )
  178. else
  179. cur=${cur:=/dev/}
  180. _filedir
  181. fi
  182. } # _smartctl()