1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers#compdef journalctl
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers_list_fields() {
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers local -a journal_fields
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers _{P,U,G}ID _COMM _EXE _CMDLINE
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _AUDIT_{SESSION,LOGINUID}
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering _SYSTEMD_USER_UNIT USER_UNIT
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _KERNEL_{DEVICE,SUBSYSTEM}
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _UDEV_{SYSNAME,DEVNODE,DEVLINK}
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers case $_jrnl_none in
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering yes) _values -s '=' 'possible fields' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;;
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering *) _describe 'possible fields' journal_fields ;;
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers_journal_none() {
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers local -a _commands _files _jrnl_none
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers # Setting use-cache will slow this down considerably
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering _jrnl_none='yes'
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering _alternative : \
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering 'files:/dev files:_files -W /dev -P /dev/' \
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering "commands:commands:($_commands[@])" \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers 'fields:fields:_list_fields'
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers_journal_fields() {
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers local -a _fields cmd
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _fields=$(_call_program fields $cmd[@])
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _fields=${_fields//'\'/'\\'}
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers _fields=${_fields//':'/'\:'}
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _fields=( ${(f)_fields} )
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering typeset -U _fields
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _describe 'possible values' _fields
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering_journal_boots() {
d7b8eec7dc7fe307d3a08b32cf1a9ad4276ce6d5Lennart Poettering local -a _bootid _previousboots
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _bootid=( ${(f)"$(_call_program bootid "$service -F _BOOT_ID")"} )
ee104e11e303499a637c5cd8157bd12ad5cc116dLennart Poettering _previousboots=( -{1..${#_bootid}} )
bb15fafe9cd815fe5bf9eae84c08aead2eb98fd7Lennart Poettering _alternative : \
d4f5a1f47dbd04f26f2ddf951c97c4cb0ebbbe62David Herrmann "offsets:boot offsets:compadd -a '_previousboots[1,-2]'" \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers "bootid:boot ids:compadd -a _bootid"
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers_arguments -s \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-h,--help}'[Show this help]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--version[Show package version]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--no-pager[Do not pipe output into a pager]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-l,--full}'[Show long fields in full]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-a,--all}'[Show all fields, including long and unprintable]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-f,--follow}'[Follow journal]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-e,--pager-end}'[Jump to the end of the journal in the pager]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-n+,--lines=}'[Number of journal entries to show]:integer' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--no-tail[Show all lines, even in follow mode]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-r,--reverse}'[Reverse output]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-x,--catalog}'[Show explanatory texts with each log line]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-q,--quiet}"[Don't show privilege warning]" \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-m,--merge}'[Show entries from all available journals]' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers {-b+,--boot=}'[Show data only from the specified boot or offset]::boot id or offset:_journal_boots' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers '--list-boots[List boots ordered by time]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-k,--dmesg}'[Show only kernel messages from the current boot]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-u+,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--user-unit=[Show data only from the specified user session unit]:units:_journal_fields USER_UNIT' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-p+,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-t+,--identifier=}'[Show only messages with the specified syslog identifier]:identifier:_journal_fields SYSLOG_IDENTIFIER' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-c+,--cursor=}'[Start showing entries from the specified cursor]:cursors:_journal_fields __CURSORS' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--after-cursor=[Start showing entries from after the specified cursor]:cursors:_journal_fields __CURSORS' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--since=[Start showing entries on or newer than the specified date]:YYYY-MM-DD HH\:MM\:SS' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--until=[Stop showing entries on or older than the specified date]:YYYY-MM-DD HH\:MM\:SS' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--system[Show system and kernel messages]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--user[Show messages from user services]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers {-D+,--directory=}'[Show journal files from directory]:directories:_directories' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--file=[Operate on specified journal files]:file:_files' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers '--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers '--new-id128[Generate a new 128 Bit ID]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--header[Show journal header information]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--disk-usage[Show total disk usage]' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers '--list-catalog[List messages in catalog]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--dump-catalog[Dump messages in catalog]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--update-catalog[Update binary catalog database]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--setup-keys[Generate a new FSS key pair]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--force[Force recreation of the FSS keys]' \
d200735e13c52dcfe36c0e066f9f6c2fbfb85a9cMichal Schmidt '--interval=[Time interval for changing the FSS sealing key]:time interval' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--verify[Verify journal file consistency]' \
8d451309667578d3a03cdfc91d6e339fb9fe64a7Kay Sievers '--verify-key=[Specify FSS verification key]:FSS key' \
1822350db15b089f094a6dbd2469842ab42c1d87Kay Sievers '*::default: _journal_none'