chiark / gitweb /
shell-completion: busctl
[elogind.git] / shell-completion / zsh / _journalctl
1 #compdef journalctl
2
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}
10                     _SYSTEMD_USER_UNIT USER_UNIT
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)
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
21 }
22
23 _journal_none() {
24     local -a _commands _files _jrnl_none
25     # Setting use-cache will slow this down considerably
26     _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
27     _jrnl_none='yes'
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
36     cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
37     _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
38     typeset -U _fields
39     _describe 'possible values' _fields
40 }
41
42 _journal_boots() {
43   local -a _bootid _previousboots
44   _bootid=( ${(fao)"$(_call_program bootid "$service -F _BOOT_ID")"}  )
45   _previousboots=( -{1..${#_bootid}} )
46   _alternative : \
47     "offsets:boot offsets:(${_previousboots[1,-2]})" \
48     "bootid:boot ids:(${_bootid[@]})"
49 }
50
51 _arguments -s \
52     {-h,--help}'[Show this help]' \
53     '--version[Show package version]' \
54     '--no-pager[Do not pipe output into a pager]' \
55     {-l,--full}'[Show long fields in full]' \
56     {-a,--all}'[Show all fields, including long and unprintable]' \
57     {-f,--follow}'[Follow journal]' \
58     {-e,--pager-end}'[Jump to the end of the journal in the pager]' \
59     {-n+,--lines=}'[Number of journal entries to show]:integer' \
60     '--no-tail[Show all lines, even in follow mode]' \
61     {-r,--reverse}'[Reverse output]' \
62     {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \
63     {-x,--catalog}'[Show explanatory texts with each log line]' \
64     {-q,--quiet}"[Don't show privilege warning]" \
65     {-m,--merge}'[Show entries from all available journals]' \
66     {-b+,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \
67     '--list-boots[List boots ordered by time]' \
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 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'