]>
Commit | Line | Data |
---|---|---|
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) | |
22 | _describe 'possible fields' journal_fields | |
23 | } | |
24 | ||
25 | _journal_none() { | |
26 | local -a _commands _files | |
4af6e458 WG |
27 | # Setting use-cache will slow this down considerably |
28 | _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} ) | |
7e83c0e0 WG |
29 | _alternative : \ |
30 | 'files:/dev files:_files -W /dev -P /dev/' \ | |
31 | "commands:commands:($_commands[@])" \ | |
32 | 'fields:fields:_list_fields' | |
33 | } | |
34 | ||
35 | _journal_fields() { | |
36 | local -a _fields cmd | |
37 | cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" ) | |
38 | _fields=( ${(f)"$(_call_program fields $cmd[@])"} ) | |
39 | typeset -U _fields | |
40 | _describe 'possible values' _fields | |
41 | } | |
42 | ||
4a8fa990 WG |
43 | _journal_boots() { |
44 | local -a _bootid _previousboots | |
45 | _bootid=( ${(fao)"$(_call_program bootid "$service -F _BOOT_ID")"} ) | |
46 | _previousboots=( -{1..${#_bootid}} ) | |
47 | _alternative : \ | |
48 | "offsets:boot offsets:(${_previousboots[1,-2]})" \ | |
49 | "bootid:boot ids:(${_bootid[@]})" | |
50 | } | |
51 | ||
7e83c0e0 WG |
52 | _arguments -s \ |
53 | {-h,--help}'[Show this help]' \ | |
54 | '--version[Show package version]' \ | |
55 | '--no-pager[Do not pipe output into a pager]' \ | |
56 | {-l,--full}'[Show long fields in full]' \ | |
57 | {-a,--all}'[Show all fields, including long and unprintable]' \ | |
58 | {-f,--follow}'[Follow journal]' \ | |
59 | {-e,--pager-end}'[Jump to the end of the journal in the pager]' \ | |
60 | {-n,--lines=}'[Number of journal entries to show]:integer' \ | |
61 | '--no-tail[Show all lines, even in follow mode]' \ | |
62 | {-r,--reverse}'[Reverse output]' \ | |
63 | {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \ | |
64 | {-x,--catalog}'[Show explanatory texts with each log line]' \ | |
65 | {-q,--quiet}"[Don't show privilege warning]" \ | |
66 | {-m,--merge}'[Show entries from all available journals]' \ | |
4a8fa990 | 67 | {-b,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \ |
7e83c0e0 WG |
68 | {-k,--dmesg}'[Show only kernel messages, Implies -b]' \ |
69 | {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \ | |
70 | '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \ | |
71 | {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \ | |
72 | {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \ | |
73 | '--after-cursor=[Start showing entries from the location in the journal after the cursor]:cursors:_journal_fields __CURSORS' \ | |
74 | '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \ | |
75 | '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \ | |
76 | {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \ | |
77 | '--system[Show system and kernel messages]' \ | |
78 | '--user[Show messages from user services]' \ | |
79 | {-D,--directory=}'[Show journal files from directory]:directories:_directories' \ | |
80 | '--file=[Operate on specified journal files]:file:_files' \ | |
81 | '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \ | |
82 | '--new-id128[Generate a new 128 Bit ID]' \ | |
83 | '--header[Show journal header information]' \ | |
84 | '--disk-usage[Show total disk usage]' \ | |
85 | '--list-catalog[List messages in catalog]' \ | |
86 | '--dump-catalog[Dump messages in catalog]' \ | |
87 | '--update-catalog[Update binary catalog database]' \ | |
88 | '--setup-keys[Generate new FSS key pair]' \ | |
89 | '--force[Force recreation of FSS keys]' \ | |
90 | '--interval=[Time interval for changing the FSS sealing key]:time interval' \ | |
91 | '--verify[Verify journal file consistency]' \ | |
92 | '--verify-key=[Specify FSS verification key]:FSS key' \ | |
93 | '*::default: _journal_none' |