From 2e6560e483b99496ab9e01d5f9f30ca5a0ef61db Mon Sep 17 00:00:00 2001 From: Nick Price Date: Tue, 19 May 2026 00:02:09 +0200 Subject: github #166: complete names of non-running FreeBSD jails --- Completion/Unix/Command/_init_d | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'Completion/Unix/Command') diff --git a/Completion/Unix/Command/_init_d b/Completion/Unix/Command/_init_d index cdc373297..939ef102e 100644 --- a/Completion/Unix/Command/_init_d +++ b/Completion/Unix/Command/_init_d @@ -1,7 +1,7 @@ #compdef -p */(init|rc[0-9S]#).d/* -local cmds script -local -a flags +local cmds script state +local -a flags line _compskip=all @@ -122,4 +122,24 @@ cmds=( $(_init_d_get_cmds) ) || return 1 (( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds || cmds=(start stop) -_arguments -s -A "-*" $flags ':init.d command:_sub_commands $cmds' +local svcname=$words[1] ret=1 + +_arguments -C -s -A "-*" $flags \ + ':init.d command:_sub_commands $cmds' \ + '*:: :->svcargs' && ret=0 + +if [[ $state == svcargs ]]; then + case $svcname in + jail) + case $line[1] in + *stop|*restart|console|status) _jails && ret=0 ;; + *) _jails -c && ret=0 ;; + esac + ;; + *) + _call_function ret _init_d-$svcname $line[1] + ;; + esac +fi + +return ret -- cgit v1.3.1