chiark / gitweb /
zsh_completion: Remove ctls function from _systemd
[elogind.git] / shell-completion / zsh / _journalctl
index 440e35d05bc72735aa682dd34a2c4de73ca96269..212bfdbc2a8426c61dce48ca20ddc776649e2254 100644 (file)
@@ -19,12 +19,18 @@ _list_fields() {
                     _KERNEL_{DEVICE,SUBSYSTEM}
                     _UDEV_{SYSNAME,DEVNODE,DEVLINK}
                     __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
-    _describe 'possible fields' journal_fields
+    case $_jrnl_none in
+        yes) _values -s '=' 'possible fields' \
+                "${journal_fields[@]}:value:_journal_fields ${words[CURRENT]%%=*}" ;;
+        *)  _describe 'possible fields' journal_fields ;;
+    esac
 }
 
 _journal_none() {
-    local -a _commands _files
-    _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
+    local -a _commands _files _jrnl_none
+    # Setting use-cache will slow this down considerably
+    _commands=( ${"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
+    _jrnl_none='yes'
     _alternative : \
         'files:/dev files:_files -W /dev -P /dev/' \
         "commands:commands:($_commands[@])" \
@@ -39,6 +45,15 @@ _journal_fields() {
     _describe 'possible values' _fields
 }
 
+_journal_boots() {
+  local -a _bootid _previousboots
+  _bootid=( ${(fao)"$(_call_program bootid "$service -F _BOOT_ID")"}  )
+  _previousboots=( -{1..${#_bootid}} )
+  _alternative : \
+    "offsets:boot offsets:(${_previousboots[1,-2]})" \
+    "bootid:boot ids:(${_bootid[@]})"
+}
+
 _arguments -s \
     {-h,--help}'[Show this help]' \
     '--version[Show package version]' \
@@ -54,7 +69,7 @@ _arguments -s \
     {-x,--catalog}'[Show explanatory texts with each log line]' \
     {-q,--quiet}"[Don't show privilege warning]" \
     {-m,--merge}'[Show entries from all available journals]' \
-    {-b,--boot}'[Show entries from the specified boot only]' \
+    {-b,--boot=}'[Show data only from the specified boot or offset]:boot id or offset:_journal_boots' \
     {-k,--dmesg}'[Show only kernel messages, Implies -b]' \
     {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
     '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \