chiark / gitweb /
Merge branch 'python-systemd-reader'
[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                              --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 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 [[ $cur = /dev* ]]; then
338                 compopt -o filenames
339                 COMPREPLY=( $(compgen -f -- "${cur}") )
340         elif [[ $cur = /* ]]; then
341                 # Append /dev/ to the list of completions, so that
342                 # after typing /<TAB><TAB> the user sees /dev/ as one
343                 # of the alternatives. Later on the rule above will
344                 # take care of showing device files in /dev/.
345                 mapfile -t field_vals < <(journalctl -F "_EXE" 2>/dev/null; echo '/dev/')
346                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur}") )
347                 if [[ "${COMPREPLY[@]}" = '/dev/' ]]; then
348                     compopt -o filenames
349                     COMPREPLY=( $(compgen -f -- "${cur}") )
350                 fi
351         elif [[ $prev = '=' ]]; then
352                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
353                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
354         else
355                 compopt -o nospace
356                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
357         fi
358 }
359 complete -F _journalctl journalctl
360
361 _coredumpctl() {
362         local i verb comps
363         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
364         local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field'
365
366         local -A VERBS=(
367             [LIST]='list'
368             [DUMP]='dump gdb'
369         )
370
371         if __contains_word "$prev" '--output -o'; then
372                 comps=$( compgen -A file -- "$cur" )
373                 compopt -o filenames
374         elif __contains_word "$prev" '--FIELD -F'; then
375                 comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
376         elif [[ $cur = -* ]]; then
377                 comps=${OPTS}
378         elif __contains_word "$prev" ${VERBS[*]} &&
379            ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
380                 compopt -o nospace
381                 COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
382                return 0
383         elif [[ $cur = *=* ]]; then
384                 mapfile -t field_vals < <(systemd-coredumpctl -F "${prev%=}" 2>/dev/null)
385                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
386                 return 0
387         elif [[ $prev = '=' ]]; then
388                 mapfile -t field_vals < <(systemd-coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
389                 comps=${field_vals[*]}
390         else
391                 for ((i=0; i <= COMP_CWORD; i++)); do
392                         if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
393                                 verb=${COMP_WORDS[i]}
394                                 break
395                         fi
396                 done
397
398                 if [[ -z $verb ]]; then
399                         comps=${VERBS[*]}
400                 elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then
401                         comps=''
402                 fi
403         fi
404
405         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
406         return 0
407 }
408 complete -F _coredumpctl systemd-coredumpctl
409
410 _timedatectl() {
411         local i verb comps
412         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
413         local OPTS='-h --help --version --adjust-system-clock --no-pager
414                     --no-ask-password -H --host'
415
416         if __contains_word "$prev" $OPTS; then
417                 case $prev in
418                         --host|-H)
419                                 comps=''
420                         ;;
421                 esac
422                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
423                 return 0
424         fi
425
426         if [[ $cur = -* ]]; then
427                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
428                 return 0
429         fi
430
431         local -A VERBS=(
432                   [BOOLEAN]='set-local-rtc set-ntp'
433                [STANDALONE]='status set-time list-timezones'
434                 [TIMEZONES]='set-timezone'
435                      [TIME]='set-time'
436         )
437
438         for ((i=0; i <= COMP_CWORD; i++)); do
439                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
440                         verb=${COMP_WORDS[i]}
441                         break
442                 fi
443         done
444
445         if [[ -z $verb ]]; then
446                 comps=${VERBS[*]}
447         elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then
448                 comps='true false'
449         elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then
450                 comps=$(command timedatectl list-timezones)
451         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then
452                 comps=''
453         fi
454
455         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
456         return 0
457 }
458 complete -F _timedatectl timedatectl
459
460 _localectl() {
461         local i verb comps
462         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
463         local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
464                     -H --host'
465
466         if __contains_word "$prev" $OPTS; then
467                 case $prev in
468                         --host|-H)
469                                 comps=''
470                         ;;
471                 esac
472                 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
473                 return 0
474         fi
475
476         if [[ $cur = -* ]]; then
477                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
478                 return 0
479         fi
480
481         local -A VERBS=(
482                [STANDALONE]='status list-locales list-keymaps'
483                   [LOCALES]='set-locale'
484                   [KEYMAPS]='set-keymap'
485                       [X11]='set-x11-keymap'
486         )
487
488         for ((i=0; i <= COMP_CWORD; i++)); do
489                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
490                         verb=${COMP_WORDS[i]}
491                         break
492                 fi
493         done
494
495         if [[ -z $verb ]]; then
496                 comps=${VERBS[*]}
497         elif __contains_word "$verb" ${VERBS[LOCALES]}; then
498                 comps=$(command localectl list-locales)
499         elif __contains_word "$verb" ${VERBS[KEYMAPS]}; then
500                 comps=$(command localectl list-keymaps)
501         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[X11]}; then
502                 comps=''
503         fi
504
505         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
506         return 0
507 }
508 complete -F _localectl localectl
509
510 _hostnamectl() {
511         local i verb comps
512         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
513         local OPTS='-h --help --version --transient --static --pretty
514                     --no-ask-password -H --host'
515
516         if [[ $cur = -* ]]; then
517                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
518                 return 0
519         fi
520
521         local -A VERBS=(
522                 [STANDALONE]='status'
523                      [ICONS]='set-icon-name'
524                       [NAME]='set-hostname'
525         )
526
527         for ((i=0; i <= COMP_CWORD; i++)); do
528                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
529                         verb=${COMP_WORDS[i]}
530                         break
531                 fi
532         done
533
534         if [[ -z $verb ]]; then
535                 comps=${VERBS[*]}
536         elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then
537                 comps=''
538         fi
539
540         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
541         return 0
542 }
543 complete -F _hostnamectl hostnamectl
544
545 __get_all_sysdevs() {
546         local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/)
547         printf '%s\n' "${devs[@]%/}"
548 }
549
550 _udevadm() {
551         local i verb comps
552         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
553         local OPTS='-h --help --version --debug'
554
555         local -A VERBS=(
556                 [INFO]='info'
557                 [TRIGGER]='trigger'
558                 [SETTLE]='settle'
559                 [CONTROL]='control'
560                 [MONITOR]='monitor'
561                 [HWDB]='hwdb'
562                 [TESTBUILTIN]='test-builtin'
563                 [TEST]='test'
564         )
565
566         for ((i=0; $i <= $COMP_CWORD; i++)); do
567                 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
568                  ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
569                         verb=${COMP_WORDS[i]}
570                         break
571                 fi
572         done
573
574         if [[ -z $verb  && $cur = -* ]]; then
575                 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
576                 return 0
577         fi
578
579         if [[ -z $verb ]]; then
580                 comps=${VERBS[*]}
581
582         elif __contains_word "$verb" ${VERBS[INFO]}; then
583                 if [[ $cur = -* ]]; then
584                         comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db'
585                 else
586                         comps=$( __get_all_sysdevs )
587                 fi
588
589         elif __contains_word "$verb" ${VERBS[TRIGGER]}; then
590                 comps='--help --verbose --dry-run --type= --action= --subsystem-match=
591                        --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match=
592                        --tag-match= --sysname-match= --parent-match='
593
594         elif __contains_word "$verb" ${VERBS[SETTLE]}; then
595                 comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet'
596
597         elif __contains_word "$verb" ${VERBS[CONTROL]}; then
598                 comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue
599                        --reload --property= --children-max= --timeout='
600
601         elif __contains_word "$verb" ${VERBS[MONITOR]}; then
602                 comps='--help --kernel --udev --property --subsystem-match= --tag-match='
603
604         elif __contains_word "$verb" ${VERBS[HWDB]}; then
605                 comps='--help --update --test='
606
607         elif __contains_word "$verb" ${VERBS[TEST]}; then
608                 if [[ $cur = -* ]]; then
609                         comps='--help --action='
610                 else
611                         comps=$( __get_all_sysdevs )
612                 fi
613
614         elif __contains_word "$verb" ${VERBS[TESTBUILTIN]}; then
615                       comps='blkid btrfs firmware hwdb input_id kmod net_id path_id usb_id uaccess'
616         fi
617
618         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
619         return 0
620 }
621 complete -F _udevadm udevadm