summaryrefslogtreecommitdiff
path: root/shell-completion/bash
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-30 19:35:24 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-30 19:35:24 +0200
commit67044a24c3fe51c9b7338ab7abe26d4afe302a36 (patch)
treed75a0f2a44fc5c8928efa1fe528795b537444828 /shell-completion/bash
parent76a9d0f1713a39471ea6c85e982fb0b447ef1315 (diff)
bash: use the actual journal fields used in the journal files for completion
Diffstat (limited to 'shell-completion/bash')
-rw-r--r--shell-completion/bash/journalctl16
1 files changed, 3 insertions, 13 deletions
diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl
index 7c8a9ce361..53bedcd92e 100644
--- a/shell-completion/bash/journalctl
+++ b/shell-completion/bash/journalctl
@@ -30,17 +30,6 @@ __get_machines() {
{ while read a b; do echo " $a"; done; } | sort -u;
}
-__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)
-
__syslog_priorities=(emerg alert crit err warning notice info debug)
_journalctl() {
@@ -79,7 +68,7 @@ _journalctl() {
comps='short short-iso short-precise short-monotonic verbose export json json-pretty json-sse cat'
;;
--field|-F)
- comps=${__journal_fields[*]}
+ comps=$(journalctl --fields | sort 2>/dev/null)
;;
--machine|-M)
comps=$( __get_machines )
@@ -125,8 +114,9 @@ _journalctl() {
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
}