# journalctl(1) completion -*- shell-script -*-
+# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
-# Copyright 2010 Ran Benita
+# Copyright © 2010 Ran Benita
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
done
}
-__journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
- ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE
- _{P,U,G}ID _COMM _EXE _CMDLINE
- _CAP_EFFECTIVE _AUDIT_{SESSION,LOGINUID}
- _SYSTEMD_{CGROUP,SESSION,{,USER_}UNIT,OWNER_UID,SLICE}
- _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
- _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
- _KERNEL_{DEVICE,SUBSYSTEM}
- _UDEV_{SYSNAME,DEVNODE,DEVLINK}
- __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
+__get_machines() {
+ local a b
+ (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \
+ { while read a b; do echo " $a"; done; } | sort -u;
+}
__syslog_priorities=(emerg alert crit err warning notice info debug)
[STANDALONE]='-a --all --full --system --user
--disk-usage -f --follow --header
-h --help -l --local --new-id128 -m --merge --no-pager
- --no-tail -q --quiet --setup-keys --this-boot --verify
+ --no-tail -q --quiet --setup-keys --verify
--version --list-catalog --update-catalog --list-boots
--show-cursor --dmesg -k --pager-end -e -r --reverse
--utc -x --catalog --no-full --force --dump-catalog
- --flush'
- [ARG]='-b --boot --this-boot -D --directory --file -F --field
- -o --output -u --unit --user-unit -p --priority'
- [ARGUNKNOWN]='-c --cursor --interval -n --lines --since --until
- --after-cursor --verify-key --identifier
- --root --machine'
+ --flush --rotate --sync --no-hostname -N --fields'
+ [ARG]='-b --boot -D --directory --file -F --field -t --identifier
+ -M --machine -o --output -u --unit --user-unit -p --priority
+ --root'
+ [ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
+ --after-cursor --verify-key
+ --vacuum-size --vacuum-time --vacuum-files --output-fields'
)
if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
case $prev in
- --boot|--this-boot|-b)
+ --boot|-b)
comps=$(journalctl -F '_BOOT_ID' 2>/dev/null)
;;
- --directory|-D)
+ --directory|-D|--root)
comps=$(compgen -d -- "$cur")
compopt -o filenames
;;
compopt -o filenames
;;
--output|-o)
- comps='short short-iso short-precise short-monotonic verbose export json json-pretty json-sse cat'
+ comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat with-unit'
;;
--field|-F)
- comps=${__journal_fields[*]}
+ comps=$(journalctl --fields | sort 2>/dev/null)
+ ;;
+ --machine|-M)
+ comps=$( __get_machines )
;;
--priority|-p)
comps=${__syslog_priorities[*]}
--user-unit)
comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null)
;;
+ --identifier|-t)
+ comps=$(journalctl -F 'SYSLOG_IDENTIFIER' 2>/dev/null)
+ ;;
*)
return 0
;;
mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
else
+ mapfile -t field_vals < <(journalctl --fields 2>/dev/null)
compopt -o nospace
- COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
+ COMPREPLY=( $(compgen -W '${field_vals[*]}' -S= -- "$cur") )
fi
}