1 # journalctl(1) completion -*- shell-script -*-
3 # This file is part of systemd.
5 # Copyright 2010 Ran Benita
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
29 (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \
30 { while read a b; do echo " $a"; done; } | sort -u;
33 __syslog_priorities=(emerg alert crit err warning notice info debug)
36 local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
38 [STANDALONE]='-a --all --full --system --user
39 --disk-usage -f --follow --header
40 -h --help -l --local --new-id128 -m --merge --no-pager
41 --no-tail -q --quiet --setup-keys --this-boot --verify
42 --version --list-catalog --update-catalog --list-boots
43 --show-cursor --dmesg -k --pager-end -e -r --reverse
44 --utc -x --catalog --no-full --force --dump-catalog
45 --flush --rotate --sync --no-hostname'
46 [ARG]='-b --boot --this-boot -D --directory --file -F --field
47 -M --machine -o --output -u --unit --user-unit -p --priority
48 --vacuum-size --vacuum-time --vacuum-files'
49 [ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
50 --after-cursor --verify-key -t --identifier
54 if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
56 --boot|--this-boot|-b)
57 comps=$(journalctl -F '_BOOT_ID' 2>/dev/null)
60 comps=$(compgen -d -- "$cur")
64 comps=$(compgen -f -- "$cur")
68 comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat'
71 comps=$(journalctl --fields | sort 2>/dev/null)
74 comps=$( __get_machines )
77 comps=${__syslog_priorities[*]}
80 comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null)
83 comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null)
86 comps=$(journalctl -F 'SYSLOG_IDENTIFIER' 2>/dev/null)
92 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
96 if [[ $cur = -* ]]; then
97 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
99 elif [[ $cur = *=* ]]; then
100 mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null)
101 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
102 elif [[ $cur = /dev* ]]; then
104 COMPREPLY=( $(compgen -f -- "${cur}") )
105 elif [[ $cur = /* ]]; then
106 # Append /dev/ to the list of completions, so that
107 # after typing /<TAB><TAB> the user sees /dev/ as one
108 # of the alternatives. Later on the rule above will
109 # take care of showing device files in /dev/.
110 mapfile -t field_vals < <(journalctl -F "_EXE" 2>/dev/null; echo '/dev/')
111 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur}") )
112 if [[ "${COMPREPLY[@]}" = '/dev/' ]]; then
114 COMPREPLY=( $(compgen -f -- "${cur}") )
116 elif [[ $prev = '=' ]]; then
117 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
118 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
120 mapfile -t field_vals < <(journalctl --fields 2>/dev/null)
122 COMPREPLY=( $(compgen -W '${field_vals[*]}' -S= -- "$cur") )
126 complete -F _journalctl journalctl