]>
Commit | Line | Data |
---|---|---|
7e83c0e0 WG |
1 | #compdef journalctl |
2 | ||
7e83c0e0 WG |
3 | _list_fields() { |
4 | local -a journal_fields | |
5 | journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} | |
6 | ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} | |
7 | _{P,U,G}ID _COMM _EXE _CMDLINE | |
8 | _AUDIT_{SESSION,LOGINUID} | |
9 | _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID} | |
9e15a18a | 10 | _SYSTEMD_USER_UNIT USER_UNIT |
7e83c0e0 WG |
11 | _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP |
12 | _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT | |
13 | _KERNEL_{DEVICE,SUBSYSTEM} | |
14 | _UDEV_{SYSNAME,DEVNODE,DEVLINK} | |
15 | __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP) | |
ca080637 WG |
16 | case $_jrnl_none in |
17 | yes) _values -s '=' 'possible fields' \ | |
18 | "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;; | |
19 | *) _describe 'possible fields' journal_fields ;; | |
20 | esac | |
7e83c0e0 WG |
21 | } |
22 | ||
23 | _journal_none() { | |
ca080637 | 24 | local -a _commands _files _jrnl_none |
4af6e458 | 25 | # Setting use-cache will slow this down considerably |
21d84318 | 26 | _commands=( ${"$(_call_program commands "$service $_sys_service_mgr -F _EXE" 2>/dev/null)"} ) |
ca080637 | 27 | _jrnl_none='yes' |
7e83c0e0 WG |
28 | _alternative : \ |
29 | 'files:/dev files:_files -W /dev -P /dev/' \ | |
30 | "commands:commands:($_commands[@])" \ | |
31 | 'fields:fields:_list_fields' | |
32 | } | |
33 | ||
34 | _journal_fields() { | |
35 | local -a _fields cmd | |
d551b8fc | 36 | cmd=("journalctl $_sys_service_mgr" "-F ${@[-1]}" "2>/dev/null" ) |
655fd9d7 DC |
37 | _fields=$(_call_program fields $cmd[@]) |
38 | _fields=${_fields//'\'/'\\'} | |
39 | _fields=${_fields//':'/'\:'} | |
40 | _fields=( ${(f)_fields} ) | |
7e83c0e0 WG |
41 | typeset -U _fields |
42 | _describe 'possible values' _fields | |
43 | } | |
44 | ||
4a8fa990 WG |
45 | _journal_boots() { |
46 | local -a _bootid _previousboots | |
c2026f28 | 47 | _bootid=( ${(f)"$(_call_program bootid "$service -F _BOOT_ID")"} ) |
4a8fa990 WG |
48 | _previousboots=( -{1..${#_bootid}} ) |
49 | _alternative : \ | |
c2026f28 EC |
50 | "offsets:boot offsets:compadd -a '_previousboots[1,-2]'" \ |
51 | "bootid:boot ids:compadd -a _bootid" | |
4a8fa990 WG |
52 | } |
53 | ||
d551b8fc DH |
54 | # Build arguments for "journalctl" to be used in completion. |
55 | # Use both --user and --system modes, they are not exclusive. | |
56 | local -a _modes; _modes=(--user --system) | |
57 | local -a _modes_with_arg; _modes_with_arg=(--directory -D --file -M --machine) | |
58 | typeset -a _sys_service_mgr | |
59 | local w i=0 n=$#words | |
60 | while (( i++ < n )); do | |
61 | w=$words[$i] | |
62 | if (( $_modes[(I)$w] )); then | |
63 | _sys_service_mgr+=($w) | |
64 | else | |
65 | if (( ${_modes_with_arg[(I)$w]} )); then | |
66 | _sys_service_mgr+=($w ${words[((++i))]}) | |
67 | fi | |
68 | fi | |
69 | done | |
7e83c0e0 WG |
70 | _arguments -s \ |
71 | {-h,--help}'[Show this help]' \ | |
72 | '--version[Show package version]' \ | |
73 | '--no-pager[Do not pipe output into a pager]' \ | |
74 | {-l,--full}'[Show long fields in full]' \ | |
75 | {-a,--all}'[Show all fields, including long and unprintable]' \ | |
76 | {-f,--follow}'[Follow journal]' \ | |
77 | {-e,--pager-end}'[Jump to the end of the journal in the pager]' \ | |
862f4963 | 78 | {-n+,--lines=}'[Number of journal entries to show]:integer' \ |
7e83c0e0 WG |
79 | '--no-tail[Show all lines, even in follow mode]' \ |
80 | {-r,--reverse}'[Reverse output]' \ | |
a02c5fe7 | 81 | {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \ |
7e83c0e0 WG |
82 | {-x,--catalog}'[Show explanatory texts with each log line]' \ |
83 | {-q,--quiet}"[Don't show privilege warning]" \ | |
84 | {-m,--merge}'[Show entries from all available journals]' \ | |
c2026f28 | 85 | {-b+,--boot=}'[Show data only from the specified boot or offset]::boot id or offset:_journal_boots' \ |
f1188074 | 86 | '--list-boots[List boots ordered by time]' \ |
c736283b | 87 | {-k,--dmesg}'[Show only kernel messages from the current boot]' \ |
862f4963 | 88 | {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \ |
9e15a18a | 89 | '--user-unit=[Show data only from the specified user session unit]:units:_journal_fields USER_UNIT' \ |
862f4963 | 90 | {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \ |
5ef80f3b | 91 | {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journal_fields SYSLOG_IDENTIFIER' \ |
c736283b JSJ |
92 | {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journal_fields __CURSORS' \ |
93 | '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journal_fields __CURSORS' \ | |
94 | '--since=[Start showing entries on or newer than the specified date]:YYYY-MM-DD HH\:MM\:SS' \ | |
95 | '--until=[Stop showing entries on or older than the specified date]:YYYY-MM-DD HH\:MM\:SS' \ | |
7e83c0e0 WG |
96 | {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \ |
97 | '--system[Show system and kernel messages]' \ | |
98 | '--user[Show messages from user services]' \ | |
ba89f806 DH |
99 | '(--directory -D -M --machine --root --file)'{-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \ |
100 | '(--directory -D -M --machine --root --file)'{-D+,--directory=}'[Show journal files from directory]:directories:_directories' \ | |
101 | '(--directory -D -M --machine --root --file)''--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \ | |
102 | '(--directory -D -M --machine --root)--file=[Operate on specified journal files]:file:_files' \ | |
7e83c0e0 WG |
103 | '--new-id128[Generate a new 128 Bit ID]' \ |
104 | '--header[Show journal header information]' \ | |
105 | '--disk-usage[Show total disk usage]' \ | |
106 | '--list-catalog[List messages in catalog]' \ | |
107 | '--dump-catalog[Dump messages in catalog]' \ | |
108 | '--update-catalog[Update binary catalog database]' \ | |
c736283b JSJ |
109 | '--setup-keys[Generate a new FSS key pair]' \ |
110 | '--force[Force recreation of the FSS keys]' \ | |
7e83c0e0 WG |
111 | '--interval=[Time interval for changing the FSS sealing key]:time interval' \ |
112 | '--verify[Verify journal file consistency]' \ | |
113 | '--verify-key=[Specify FSS verification key]:FSS key' \ | |
114 | '*::default: _journal_none' |