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