]> git.ipfire.org Git - thirdparty/systemd.git/blame - shell-completion/zsh/_journalctl
zsh_completion: Fix single letter args
[thirdparty/systemd.git] / shell-completion / zsh / _journalctl
CommitLineData
7e83c0e0
WG
1#compdef journalctl
2
3_outputmodes() {
4 local -a _output_opts
5 _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
6 _describe -t output 'output mode' _output_opts || compadd "$@"
7}
8
9_list_fields() {
10 local -a journal_fields
11 journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
12 ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
13 _{P,U,G}ID _COMM _EXE _CMDLINE
14 _AUDIT_{SESSION,LOGINUID}
15 _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
16 _SYSTEMD_USER_UNIT
17 _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
18 _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
19 _KERNEL_{DEVICE,SUBSYSTEM}
20 _UDEV_{SYSNAME,DEVNODE,DEVLINK}
21 __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
ca080637
WG
22 case $_jrnl_none in
23 yes) _values -s '=' 'possible fields' \
24 "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;;
25 *) _describe 'possible fields' journal_fields ;;
26 esac
7e83c0e0
WG
27}
28
29_journal_none() {
ca080637 30 local -a _commands _files _jrnl_none
4af6e458
WG
31 # Setting use-cache will slow this down considerably
32 _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
ca080637 33 _jrnl_none='yes'
7e83c0e0
WG
34 _alternative : \
35 'files:/dev files:_files -W /dev -P /dev/' \
36 "commands:commands:($_commands[@])" \
37 'fields:fields:_list_fields'
38}
39
40_journal_fields() {
41 local -a _fields cmd
42 cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
43 _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
44 typeset -U _fields
45 _describe 'possible values' _fields
46}
47
4a8fa990
WG
48_journal_boots() {
49 local -a _bootid _previousboots
50 _bootid=( ${(fao)"$(_call_program bootid "$service -F _BOOT_ID")"} )
51 _previousboots=( -{1..${#_bootid}} )
52 _alternative : \
53 "offsets:boot offsets:(${_previousboots[1,-2]})" \
54 "bootid:boot ids:(${_bootid[@]})"
55}
56
7e83c0e0
WG
57_arguments -s \
58 {-h,--help}'[Show this help]' \
59 '--version[Show package version]' \
60 '--no-pager[Do not pipe output into a pager]' \
61 {-l,--full}'[Show long fields in full]' \
62 {-a,--all}'[Show all fields, including long and unprintable]' \
63 {-f,--follow}'[Follow journal]' \
64 {-e,--pager-end}'[Jump to the end of the journal in the pager]' \
862f4963 65 {-n+,--lines=}'[Number of journal entries to show]:integer' \
7e83c0e0
WG
66 '--no-tail[Show all lines, even in follow mode]' \
67 {-r,--reverse}'[Reverse output]' \
862f4963 68 {-o+,--output=}'[Change journal output mode]:output modes:_outputmodes' \
7e83c0e0
WG
69 {-x,--catalog}'[Show explanatory texts with each log line]' \
70 {-q,--quiet}"[Don't show privilege warning]" \
71 {-m,--merge}'[Show entries from all available journals]' \
862f4963 72 {-b+,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \
7e83c0e0 73 {-k,--dmesg}'[Show only kernel messages, Implies -b]' \
862f4963 74 {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
7e83c0e0 75 '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
862f4963
WG
76 {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
77 {-c+,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
7e83c0e0
WG
78 '--after-cursor=[Start showing entries from the location in the journal after the cursor]:cursors:_journal_fields __CURSORS' \
79 '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
80 '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
81 {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
82 '--system[Show system and kernel messages]' \
83 '--user[Show messages from user services]' \
862f4963 84 {-D+,--directory=}'[Show journal files from directory]:directories:_directories' \
7e83c0e0
WG
85 '--file=[Operate on specified journal files]:file:_files' \
86 '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
87 '--new-id128[Generate a new 128 Bit ID]' \
88 '--header[Show journal header information]' \
89 '--disk-usage[Show total disk usage]' \
90 '--list-catalog[List messages in catalog]' \
91 '--dump-catalog[Dump messages in catalog]' \
92 '--update-catalog[Update binary catalog database]' \
93 '--setup-keys[Generate new FSS key pair]' \
94 '--force[Force recreation of FSS keys]' \
95 '--interval=[Time interval for changing the FSS sealing key]:time interval' \
96 '--verify[Verify journal file consistency]' \
97 '--verify-key=[Specify FSS verification key]:FSS key' \
98 '*::default: _journal_none'