chiark / gitweb /
efi: add efi boot generator that automatically mounts the ESP to /boot
[elogind.git] / shell-completion / systemd-bash-completion.sh
1 # This file is part of systemd.
2 #
3 # Copyright 2010 Ran Benita
4 #
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
9 #
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
17
18 __systemctl() {
19         systemctl --full --no-legend "$@"
20 }
21
22 __contains_word () {
23         local word=$1; shift
24         for w in $*; do [[ $w = $word ]] && return 0; done
25         return 1
26 }
27
28 __filter_units_by_property () {
29         local property=$1 value=$2 ; shift 2
30         local units=("$@")
31         local props
32         IFS=$'\n' read -rd '' -a props < \
33             <(__systemctl show --property "$property" -- "${units[@]}")
34         for ((i=0; $i < ${#units[*]}; i++)); do
35                 if [[ "${props[i]}" = "$property=$value" ]]; then
36                         printf "%s\n" "${units[i]}"
37                 fi
38         done
39 }
40
41 __get_all_units      () { __systemctl list-units --all \
42         | { while read -r a b; do printf "%s\n" "$a"; done; }; }
43 __get_active_units   () { __systemctl list-units       \
44         | { while read -r a b; do printf "%s\n" "$a"; done; }; }
45 __get_inactive_units () { __systemctl list-units --all \
46         | { while read -r a b c d; do [[ $c == "inactive" ]] && printf "%s\n" "$a"; done; }; }
47 __get_failed_units   () { __systemctl list-units       \
48         | { while read -r a b c d; do [[ $c == "failed"   ]] && printf "%s\n" "$a"; done; }; }
49 __get_enabled_units  () { __systemctl list-unit-files  \
50         | { while read -r a b c  ; do [[ $b == "enabled"  ]] && printf "%s\n" "$a"; done; }; }
51 __get_disabled_units () { __systemctl list-unit-files  \
52         | { while read -r a b c  ; do [[ $b == "disabled" ]] && printf "%s\n" "$a"; done; }; }
53 __get_masked_units   () { __systemctl list-unit-files  \
54         | { while read -r a b c  ; do [[ $b == "masked"   ]] && printf "%s\n" "$a"; done; }; }
55
56 _systemctl () {
57         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
58         local i verb comps
59
60         local -A OPTS=(
61                [STANDALONE]='--all -a --defaults --fail --ignore-dependencies --failed --force -f --full --global
62                              --help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall
63                              --order --require --quiet -q --privileged -P --system --user --version --runtime'
64                       [ARG]='--host -H --kill-mode --kill-who --property -p --signal -s --type -t --root'
65         )
66
67         if __contains_word "$prev" ${OPTS[ARG]}; then
68                 case $prev in
69                         --signal|-s)
70                                 comps=$(compgen -A signal)
71                         ;;
72                         --type|-t)
73                                 comps='automount device mount path service snapshot socket swap target timer'
74                         ;;
75                         --kill-who)
76                                 comps='all control main'
77                         ;;
78                         --kill-mode)
79                                 comps='control-group process'
80                         ;;
81                         --root)
82                                 comps=$(compgen -A directory -- "$cur" )
83                                 compopt -o filenames
84                         ;;
85                         --host|-H)
86                                 comps=$(compgen -A hostname)
87                         ;;
88                         --property|-p)
89                                 comps=''
90                         ;;
91                 esac
92                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
93                 return 0
94         fi
95
96
97         if [[ "$cur" = -* ]]; then
98                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
99                 return 0
100         fi
101
102         local -A VERBS=(
103                 [ALL_UNITS]='is-active is-failed is-enabled status show mask preset'
104             [ENABLED_UNITS]='disable reenable'
105            [DISABLED_UNITS]='enable'
106              [FAILED_UNITS]='reset-failed'
107           [STARTABLE_UNITS]='start'
108           [STOPPABLE_UNITS]='stop condstop kill try-restart condrestart'
109          [ISOLATABLE_UNITS]='isolate'
110          [RELOADABLE_UNITS]='reload condreload reload-or-try-restart force-reload'
111         [RESTARTABLE_UNITS]='restart reload-or-restart'
112              [MASKED_UNITS]='unmask'
113                      [JOBS]='cancel'
114                 [SNAPSHOTS]='delete'
115                      [ENVS]='set-environment unset-environment'
116                [STANDALONE]='daemon-reexec daemon-reload default dot dump
117                              emergency exit halt hibernate hybrid-sleep kexec list-jobs
118                              list-units list-unit-files poweroff reboot rescue
119                              show-environment suspend'
120                      [NAME]='snapshot load'
121                      [FILE]='link'
122         )
123
124         for ((i=0; $i <= $COMP_CWORD; i++)); do
125                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
126                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
127                         verb=${COMP_WORDS[i]}
128                         break
129                 fi
130         done
131
132         if   [[ -z $verb ]]; then
133                 comps="${VERBS[*]}"
134
135         elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then
136                 comps=$( __get_all_units )
137
138         elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then
139                 comps=$( __get_enabled_units )
140
141         elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
142                 comps=$( __get_disabled_units )
143
144         elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
145                 comps=$( __filter_units_by_property CanStart yes \
146                       $( __get_inactive_units \
147                         | while read -r line; do \
148                                 [[ "$line" =~ \.(device|snapshot)$ ]] || printf "%s\n" "$line"; \
149                         done ))
150
151         elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
152                 comps=$( __filter_units_by_property CanStart yes \
153                       $( __get_all_units \
154                         | while read -r line; do \
155                                 [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || printf "%s\n" "$line"; \
156                         done ))
157
158         elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
159                 comps=$( __filter_units_by_property CanStop yes \
160                       $( __get_active_units ) )
161
162         elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then
163                 comps=$( __filter_units_by_property CanReload yes \
164                       $( __get_active_units ) )
165
166         elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then
167                 comps=$( __filter_units_by_property AllowIsolate yes \
168                       $( __get_all_units ) )
169
170         elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then
171                 comps=$( __get_failed_units )
172
173         elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then
174                 comps=$( __get_masked_units )
175
176         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then
177                 comps=''
178
179         elif __contains_word "$verb" ${VERBS[JOBS]}; then
180                 comps=$( __systemctl list-jobs | { while read -r a b; do printf "%s\n" "$a"; done; } )
181
182         elif __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then
183                 comps=$( __systemctl list-units --type snapshot --full --all \
184                         | { while read -r a b; do printf "%s\n" "$a"; done; } )
185
186         elif __contains_word "$verb" ${VERBS[ENVS]}; then
187                 comps=$( __systemctl show-environment \
188                     | while read -r line; do printf "%s\n" "${line%%=*}=";done )
189                 compopt -o nospace
190
191         elif __contains_word "$verb" ${VERBS[FILE]}; then
192                 comps=$( compgen -A file -- "$cur" )
193                 compopt -o filenames
194         fi
195
196         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
197         return 0
198 }
199 complete -F _systemctl systemctl
200
201 __get_all_sessions () { loginctl list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
202 __get_all_users    () { loginctl list-users    | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
203 __get_all_seats    () { loginctl list-seats    | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
204
205 _loginctl () {
206         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
207         local i verb comps
208
209         local -A OPTS=(
210                [STANDALONE]='--all -a --help -h --no-pager --privileged -P --version'
211                       [ARG]='--host -H --kill-who --property -p --signal -s'
212         )
213
214         if __contains_word "$prev" ${OPTS[ARG]}; then
215                 case $prev in
216                         --signal|-s)
217                                 comps=$(compgen -A signal)
218                         ;;
219                         --kill-who)
220                                 comps='all leader'
221                         ;;
222                         --host|-H)
223                                 comps=$(compgen -A hostname)
224                         ;;
225                         --property|-p)
226                                 comps=''
227                         ;;
228                 esac
229                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
230                 return 0
231         fi
232
233
234         if [[ "$cur" = -* ]]; then
235                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
236                 return 0
237         fi
238
239         local -A VERBS=(
240                 [SESSIONS]='session-status show-session activate lock-session unlock-session terminate-session kill-session'
241                 [USERS]='user-status show-user enable-linger disable-linger terminate-user kill-user'
242                 [SEATS]='seat-status show-seat terminate-seat'
243                 [STANDALONE]='list-sessions list-users list-seats flush-devices'
244                 [ATTACH]='attach'
245         )
246
247         for ((i=0; $i <= $COMP_CWORD; i++)); do
248                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
249                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
250                         verb=${COMP_WORDS[i]}
251                         break
252                 fi
253         done
254
255         if   [[ -z $verb ]]; then
256                 comps="${VERBS[*]}"
257
258         elif __contains_word "$verb" ${VERBS[SESSIONS]}; then
259                 comps=$( __get_all_sessions )
260
261         elif __contains_word "$verb" ${VERBS[USERS]}; then
262                 comps=$( __get_all_users )
263
264         elif __contains_word "$verb" ${VERBS[SEATS]}; then
265                 comps=$( __get_all_seats )
266
267         elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
268                 comps=''
269
270         elif __contains_word "$verb" ${VERBS[ATTACH]}; then
271                 if [[ $prev = $verb ]]; then
272                         comps=$( __get_all_seats )
273                 else
274                         comps=$(compgen -A file -- "$cur" )
275                         compopt -o filenames
276                 fi
277         fi
278
279         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
280         return 0
281 }
282 complete -F _loginctl loginctl
283
284 __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
285                   ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE
286                   _{P,U,G}ID _COMM _EXE _CMDLINE
287                   _AUDIT_{SESSION,LOGINUID}
288                   _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
289                   _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
290                   _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
291                   _KERNEL_{DEVICE,SUBSYSTEM}
292                   _UDEV_{SYSNAME,DEVNODE,DEVLINK}
293                   __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
294
295 _journalctl() {
296         local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
297         local -A OPTS=(
298                 [STANDALONE]='-a --all --full
299                               -b --this-boot --disk-usage -f --follow --header
300                               -h --help -l --local --new-id128 -m --merge --no-pager
301                               --no-tail -q --quiet --setup-keys --this-boot --verify
302                               --version --list-catalog --update-catalog'
303                        [ARG]='-D --directory -F --field -o --output -u --unit'
304                 [ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until
305                               --verify-key'
306         )
307
308         if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
309                 case $prev in
310                         --directory|-D)
311                                 comps=$(compgen -d -- "$cur")
312                                 compopt -o filenames
313                         ;;
314                         --output|-o)
315                                 comps='short short-monotonic verbose export json cat'
316                         ;;
317                         --field|-F)
318                                 comps=${__journal_fields[*]}
319                         ;;
320                         --unit|-u)
321                                 comps=$(journalctl -F '_SYSTEMD_UNIT')
322                         ;;
323                         *)
324                                 return 0
325                         ;;
326                 esac
327                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
328                 return 0
329         fi
330
331         if [[ $cur = -* ]]; then
332                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
333                 return 0
334         elif [[ $cur = *=* ]]; then
335                 mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null)
336                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
337         elif [[ $prev = '=' ]]; then
338                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
339                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
340         else
341                 compopt -o nospace
342                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
343         fi
344 }
345 complete -F _journalctl journalctl
346
347 _coredumpctl() {
348         local i verb comps
349         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
350         local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field'
351
352         local -A VERBS=(
353             [LIST]='list'
354             [DUMP]='dump gdb'
355         )
356
357         if __contains_word "$prev" '--output -o'; then
358                 comps=$( compgen -A file -- "$cur" )
359                 compopt -o filenames
360         elif __contains_word "$prev" '--FIELD -F'; then
361                 comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
362         elif [[ $cur = -* ]]; then
363                 comps=${OPTS}
364         elif __contains_word "$prev" ${VERBS[*]} &&
365            ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
366                 compopt -o nospace
367                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
368                return 0
369         elif [[ $cur = *=* ]]; then
370                 mapfile -t field_vals < <(systemd-coredumpctl -F "${prev%=}" 2>/dev/null)
371                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
372                 return 0
373         elif [[ $prev = '=' ]]; then
374                 mapfile -t field_vals < <(systemd-coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
375                 comps=${field_vals[*]}
376         else
377                 for ((i=0; i <= COMP_CWORD; i++)); do
378                         if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
379                                 verb=${COMP_WORDS[i]}
380                                 break
381                         fi
382                 done
383
384                 if [[ -z $verb ]]; then
385                         comps=${VERBS[*]}
386                 elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
387                         comps=''
388                 fi
389         fi
390
391         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
392         return 0
393 }
394 complete -F _coredumpctl systemd-coredumpctl
395
396 _timedatectl() {
397         local i verb comps
398         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
399         local OPTS='-h --help --version --adjust-system-clock --no-pager
400                     --no-ask-password -H --host'
401
402         if __contains_word "$prev" $OPTS; then
403                 case $prev in
404                         --host|-H)
405                                 comps=''
406                         ;;
407                 esac
408                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
409                 return 0
410         fi
411
412         if [[ $cur = -* ]]; then
413                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
414                 return 0
415         fi
416
417         local -A VERBS=(
418                   [BOOLEAN]='set-local-rtc set-ntp'
419                [STANDALONE]='status set-time list-timezones'
420                 [TIMEZONES]='set-timezone'
421                      [TIME]='set-time'
422         )
423
424         for ((i=0; i <= COMP_CWORD; i++)); do
425                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
426                         verb=${COMP_WORDS[i]}
427                         break
428                 fi
429         done
430
431         if [[ -z $verb ]]; then
432                 comps=${VERBS[*]}
433         elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then
434                 comps='true false'
435         elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then
436                 comps=$(command timedatectl list-timezones)
437         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
438                 comps=''
439         fi
440
441         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
442         return 0
443 }
444 complete -F _timedatectl timedatectl
445
446 _localectl() {
447         local i verb comps
448         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
449         local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
450                     -H --host'
451
452         if __contains_word "$prev" $OPTS; then
453                 case $prev in
454                         --host|-H)
455                                 comps=''
456                         ;;
457                 esac
458                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
459                 return 0
460         fi
461
462         if [[ $cur = -* ]]; then
463                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
464                 return 0
465         fi
466
467         local -A VERBS=(
468                [STANDALONE]='status list-locales list-keymaps'
469                   [LOCALES]='set-locale'
470                   [KEYMAPS]='set-keymap'
471                       [X11]='set-x11-keymap'
472         )
473
474         for ((i=0; i <= COMP_CWORD; i++)); do
475                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
476                         verb=${COMP_WORDS[i]}
477                         break
478                 fi
479         done
480
481         if [[ -z $verb ]]; then
482                 comps=${VERBS[*]}
483         elif __contains_word "$verb" ${VERBS[LOCALES]}; then
484                 comps=$(command localectl list-locales)
485         elif __contains_word "$verb" ${VERBS[KEYMAPS]}; then
486                 comps=$(command localectl list-keymaps)
487         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[X11]}; then
488                 comps=''
489         fi
490
491         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
492         return 0
493 }
494 complete -F _localectl localectl
495
496 _hostnamectl() {
497         local i verb comps
498         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
499         local OPTS='-h --help --version --transient --static --pretty
500                     --no-ask-password -H --host'
501
502         if [[ $cur = -* ]]; then
503                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
504                 return 0
505         fi
506
507         local -A VERBS=(
508                 [STANDALONE]='status'
509                      [ICONS]='set-icon-name'
510                       [NAME]='set-hostname'
511         )
512
513         for ((i=0; i <= COMP_CWORD; i++)); do
514                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
515                         verb=${COMP_WORDS[i]}
516                         break
517                 fi
518         done
519
520         if [[ -z $verb ]]; then
521                 comps=${VERBS[*]}
522         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then
523                 comps=''
524         fi
525
526         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
527         return 0
528 }
529 complete -F _hostnamectl hostnamectl
530
531 __get_all_sysdevs() {
532         local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
533         printf '%s\n' "${devs[@]%/}"
534 }
535
536 _udevadm() {
537         local i verb comps
538         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
539         local OPTS='-h --help --version --debug'
540
541         local -A VERBS=(
542                 [INFO]='info'
543                 [TRIGGER]='trigger'
544                 [SETTLE]='settle'
545                 [CONTROL]='control'
546                 [MONITOR]='monitor'
547                 [HWDB]='hwdb'
548                 [TESTBUILTIN]='test-builtin'
549                 [TEST]='test'
550         )
551
552         for ((i=0; $i <= $COMP_CWORD; i++)); do
553                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
554                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
555                         verb=${COMP_WORDS[i]}
556                         break
557                 fi
558         done
559
560         if [[ -z $verb  && $cur = -* ]]; then
561                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
562                 return 0
563         fi
564
565         if [[ -z $verb ]]; then
566                 comps=${VERBS[*]}
567
568         elif __contains_word "$verb" ${VERBS[INFO]}; then
569                 if [[ $cur = -* ]]; then
570                         comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
571                 else
572                         comps=$( __get_all_sysdevs )
573                 fi
574
575         elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
576                 comps='--help --verbose --dry-run --type= --action= --subsystem-match=
577                        --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
578                        --tag-match= --sysname-match= --parent-match='
579
580         elif __contains_word "$verb" ${VERBS[SETTLE]}; then
581                 comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
582
583         elif __contains_word "$verb" ${VERBS[CONTROL]}; then
584                 comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
585                        --reload --property= --children-max= --timeout='
586
587         elif __contains_word "$verb" ${VERBS[MONITOR]}; then
588                 comps='--help --kernel --udev --property --subsystem-match= --tag-match='
589
590         elif __contains_word "$verb" ${VERBS[HWDB]}; then
591                 comps='--help --update --test='
592
593         elif __contains_word "$verb" ${VERBS[TEST]}; then
594                 if [[ $cur = -* ]]; then
595                         comps='--help --action='
596                 else
597                         comps=$( __get_all_sysdevs )
598                 fi
599
600         elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
601                       comps='blkid btrfs firmware hwdb input_id kmod net_id path_id usb_id uaccess'
602         fi
603
604         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
605         return 0
606 }
607 complete -F _udevadm udevadm