Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: update completions for some common Unix commands
- X-seq: zsh-workers 35051
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: Re: PATCH: update completions for some common Unix commands
- Date: Thu, 7 May 2015 00:40:59 +0000
- Cc: Zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=pRqpaEjx84/+7D1iO43QOCWyvHk=; b=LzC9zI D76P5WI+1VX7YVab8g3ElBGw1pXTy8eSv9kNywzXx+wZRMsITLAANxFwPiYRwgUu BLnR2PFzsh+YOL+3UwnFzOX25y/ELqwvadFY97GQR5clh3/P4/wdqmfvwauoAjUc Cp9N7WUp6amFmImJUM5tnqtz7+myb8pciySUs=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=pRqpaEjx84/+7D1iO43QOCWyvHk=; b=sOGnd yppJqdAwBWW6xfn/IvL2L1dZrHIwX09PGmndVUaljbTMRoqlZvZnFwY91uG7uCFh Eze7mos3EQXfUuEliBjflTPEIOaGYNOJhBAHYbucNQT7mjjt6iNbn50YAohU9aLu 02azezsjcLyYHfGOZ4JXXjdiBhVTsXW7iUCpqk=
- In-reply-to: <4262.1430949497@quattro>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <10432.1430474309@quattro> <20150505215445.GC2020@tarsus.local2> <4262.1430949497@quattro>
Oliver Kiddle wrote on Wed, May 06, 2015 at 23:58:17 +0200:
> Daniel Shahaf wrote:
> > Should jail names be offered as completions, rather than just as
> > descriptions? I think most jail-related commands commands accept either
> > jname or jid to identify a jail.
>
> ps and pgrep both seem to require IDs but allow 0 for processes that are
> not part of a jail. Do jail-related commands accepting names have a name
> for the host system?
None do that I know of. Neither the fully-qualified hostname nor the
base hostname works (tested with either ps and jexec).
> There's probably commands somewhere that can take either jids or names
> (jls being one example) but that's not yet handled.
How about handling those by completing just the jnames and not the jids?
After all, jnames are stable (across jail stop/start cycles) but jids
aren't.
When "0" is accepted, we could complete it in addition to running jails'
names. So for example, 'ps -J' would complete 0 plus running jnames,
and jexec would complete just jnames:
diff --git a/Completion/BSD/Command/_jexec b/Completion/BSD/Command/_jexec
new file mode 100644
index 0000000..99dcb00
--- /dev/null
+++ b/Completion/BSD/Command/_jexec
@@ -0,0 +1,7 @@
+#compdef jexec
+
+_arguments -s -S : \
+ '-u[host username]:host username the command will run as:_users' \
+ '-U[jail username]:jail username the command will run as' \
+ '(-)1:jail to execute the command in:_jails -o name' \
+ '*:::arguments: _normal'
> +local addhost host param desc=1
> +local -a args expl
> +zparseopts -D -K -E 0=addhost o:=param
> +param=${param[2]:-jid}
> +
> +jails=( ${${(f)"$(_call_program jails jls $param name)"}/ /:} )
Missing 'local -a jails'.
Thanks,
Daniel
P.S. Until FreeBSD 10.1 or so, rc.d/jail would set the jname equal to
the jid, so the distinction between jname/jid completion is harder to
see in those systems.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author