_journalctl revision 4af6e458e5a683b89032d560eb353c2272d3d564
7e83c0e03fbf397167822e170d97c3a210658768William Giokas#compdef journalctl
7e83c0e03fbf397167822e170d97c3a210658768William Giokas
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_outputmodes() {
7e83c0e03fbf397167822e170d97c3a210658768William Giokas local -a _output_opts
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _describe -t output 'output mode' _output_opts || compadd "$@"
7e83c0e03fbf397167822e170d97c3a210658768William Giokas}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_list_fields() {
7e83c0e03fbf397167822e170d97c3a210658768William Giokas local -a journal_fields
7e83c0e03fbf397167822e170d97c3a210658768William Giokas journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _{P,U,G}ID _COMM _EXE _CMDLINE
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _AUDIT_{SESSION,LOGINUID}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _SYSTEMD_USER_UNIT
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _KERNEL_{DEVICE,SUBSYSTEM}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _UDEV_{SYSNAME,DEVNODE,DEVLINK}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _describe 'possible fields' journal_fields
7e83c0e03fbf397167822e170d97c3a210658768William Giokas}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_journal_none() {
7e83c0e03fbf397167822e170d97c3a210658768William Giokas local -a _commands _files
4af6e458e5a683b89032d560eb353c2272d3d564William Giokas # Setting use-cache will slow this down considerably
4af6e458e5a683b89032d560eb353c2272d3d564William Giokas _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _alternative : \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas 'files:/dev files:_files -W /dev -P /dev/' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas "commands:commands:($_commands[@])" \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas 'fields:fields:_list_fields'
7e83c0e03fbf397167822e170d97c3a210658768William Giokas}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_journal_fields() {
7e83c0e03fbf397167822e170d97c3a210658768William Giokas local -a _fields cmd
7e83c0e03fbf397167822e170d97c3a210658768William Giokas cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
7e83c0e03fbf397167822e170d97c3a210658768William Giokas typeset -U _fields
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _describe 'possible values' _fields
7e83c0e03fbf397167822e170d97c3a210658768William Giokas}
7e83c0e03fbf397167822e170d97c3a210658768William Giokas
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas_journal_boots() {
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas local -a _bootid _previousboots
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas _bootid=( ${(fao)"$(_call_program bootid "$service -F _BOOT_ID")"} )
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas _previousboots=( -{1..${#_bootid}} )
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas _alternative : \
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas "offsets:boot offsets:(${_previousboots[1,-2]})" \
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas "bootid:boot ids:(${_bootid[@]})"
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas}
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_arguments -s \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-h,--help}'[Show this help]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--version[Show package version]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--no-pager[Do not pipe output into a pager]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-l,--full}'[Show long fields in full]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-a,--all}'[Show all fields, including long and unprintable]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-f,--follow}'[Follow journal]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-e,--pager-end}'[Jump to the end of the journal in the pager]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-n,--lines=}'[Number of journal entries to show]:integer' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--no-tail[Show all lines, even in follow mode]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-r,--reverse}'[Reverse output]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-x,--catalog}'[Show explanatory texts with each log line]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-q,--quiet}"[Don't show privilege warning]" \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-m,--merge}'[Show entries from all available journals]' \
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas {-b,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-k,--dmesg}'[Show only kernel messages, Implies -b]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--after-cursor=[Start showing entries from the location in the journal after the cursor]:cursors:_journal_fields __CURSORS' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--system[Show system and kernel messages]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--user[Show messages from user services]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--file=[Operate on specified journal files]:file:_files' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--new-id128[Generate a new 128 Bit ID]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--header[Show journal header information]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--disk-usage[Show total disk usage]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--list-catalog[List messages in catalog]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--dump-catalog[Dump messages in catalog]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--update-catalog[Update binary catalog database]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--setup-keys[Generate new FSS key pair]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--force[Force recreation of FSS keys]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--interval=[Time interval for changing the FSS sealing key]:time interval' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--verify[Verify journal file consistency]' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '--verify-key=[Specify FSS verification key]:FSS key' \
7e83c0e03fbf397167822e170d97c3a210658768William Giokas '*::default: _journal_none'