7e83c0e03fbf397167822e170d97c3a210658768William Giokas#compdef journalctl
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}
9e15a18acd19bf80faef774ee92877024ef599a5William Giokas _SYSTEMD_USER_UNIT 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)
ca08063781666a530993f7c88db1256044689c24William Giokas case $_jrnl_none in
ca08063781666a530993f7c88db1256044689c24William Giokas yes) _values -s '=' 'possible fields' \
ca08063781666a530993f7c88db1256044689c24William Giokas "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;;
ca08063781666a530993f7c88db1256044689c24William Giokas *) _describe 'possible fields' journal_fields ;;
7e83c0e03fbf397167822e170d97c3a210658768William Giokas_journal_none() {
ca08063781666a530993f7c88db1256044689c24William Giokas local -a _commands _files _jrnl_none
4af6e458e5a683b89032d560eb353c2272d3d564William Giokas # Setting use-cache will slow this down considerably
4af6e458e5a683b89032d560eb353c2272d3d564William Giokas _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
ca08063781666a530993f7c88db1256044689c24William Giokas _jrnl_none='yes'
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_journal_fields() {
7e83c0e03fbf397167822e170d97c3a210658768William Giokas local -a _fields cmd
7e83c0e03fbf397167822e170d97c3a210658768William Giokas cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
655fd9d71f22dc3efe4f4fae2da633c93cb67292Douglas Christman _fields=$(_call_program fields $cmd[@])
655fd9d71f22dc3efe4f4fae2da633c93cb67292Douglas Christman _fields=${_fields//'\'/'\\'}
655fd9d71f22dc3efe4f4fae2da633c93cb67292Douglas Christman _fields=${_fields//':'/'\:'}
655fd9d71f22dc3efe4f4fae2da633c93cb67292Douglas Christman _fields=( ${(f)_fields} )
7e83c0e03fbf397167822e170d97c3a210658768William Giokas typeset -U _fields
7e83c0e03fbf397167822e170d97c3a210658768William Giokas _describe 'possible values' _fields
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas_journal_boots() {
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas local -a _bootid _previousboots
c2026f28bdc64c608e9b00e8f7916c82f44ec610Eric Cook _bootid=( ${(f)"$(_call_program bootid "$service -F _BOOT_ID")"} )
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas _previousboots=( -{1..${#_bootid}} )
4a8fa990693edc47ac2192bf088a6e22e2390b41William Giokas _alternative : \
c2026f28bdc64c608e9b00e8f7916c82f44ec610Eric Cook "offsets:boot offsets:compadd -a '_previousboots[1,-2]'" \
c2026f28bdc64c608e9b00e8f7916c82f44ec610Eric Cook "bootid:boot ids:compadd -a _bootid"
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]' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William 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]' \
a02c5fe7cbad3ca0536286ceab0bde5fb1c0ba13William Giokas {-o+,--output=}'[Change journal output mode]:output modes:_sd_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]' \
c2026f28bdc64c608e9b00e8f7916c82f44ec610Eric Cook {-b+,--boot=}'[Show data only from the specified boot or offset]::boot id or offset:_journal_boots' \
f11880744c27209a42f502c690db86b38d2db14bZbigniew Jędrzejewski-Szmek '--list-boots[List boots ordered by time]' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John {-k,--dmesg}'[Show only kernel messages from the current boot]' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William Giokas {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
9e15a18acd19bf80faef774ee92877024ef599a5William Giokas '--user-unit=[Show data only from the specified user session unit]:units:_journal_fields USER_UNIT' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William Giokas {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
5ef80f3bbb027526a32cce9ce060fb15c7ec5c98Zbigniew Jędrzejewski-Szmek {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journal_fields SYSLOG_IDENTIFIER' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journal_fields __CURSORS' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journal_fields __CURSORS' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John '--since=[Start showing entries on or newer than the specified date]:YYYY-MM-DD HH\:MM\:SS' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John '--until=[Stop showing entries on or older than 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]' \
b178d279d92fdf002b18dd2f06f2353af14d0a6eRonny Chevalier {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
862f4963c6f7778cea9e715eeb11ea959eba6db3William 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]' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John '--setup-keys[Generate a new FSS key pair]' \
c736283bfb81f5b00756e08a13946c113a41527fJason St. John '--force[Force recreation of the 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'