summaryrefslogtreecommitdiffstats
path: root/Completion/BSD
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2015-05-11 12:11:25 +0200
committerOliver Kiddle <opk@zsh.org>2015-05-11 12:11:32 +0200
commit5b7e50dcd0786a47e180499c9a7a28cffcd73c1d (patch)
tree087dd99331442b8b24825477262f723216d22f98 /Completion/BSD
parent35078: Add backslash quoting to parameter (b) flag from 35067. (diff)
downloadzsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.gz
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.bz2
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.lz
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.xz
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.zst
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.zip
35049: allow jail completion to include jid 0 for the host and to
complete jails by any parameter
Diffstat (limited to 'Completion/BSD')
-rw-r--r--Completion/BSD/Type/_jails32
1 files changed, 30 insertions, 2 deletions
diff --git a/Completion/BSD/Type/_jails b/Completion/BSD/Type/_jails
index 36bffeceb..89e34ba4f 100644
--- a/Completion/BSD/Type/_jails
+++ b/Completion/BSD/Type/_jails
@@ -1,5 +1,33 @@
#autoload
-jails=( ${${${${(f)"$(_call_program jails jls -n)"}##*jid=}/ name=/:}%% *} )
+# Options:
+#
+# -0 include jid 0 as a match for the host system
+# -o param jail parameter to complete instead of jid -
+# e.g. name, path, ip4.addr, host.hostname
-_describe -t jails jail jails "$@"
+local addhost host param desc=1
+local -a jails args expl
+zparseopts -D -K -E 0=addhost o:=param
+param=${param[2]:-name}
+
+jails=( ${${(f)"$(_call_program jails jls $param name)"}/ /:} )
+case $param in
+ jid) host=0 ;;
+ name)
+ host=0
+ desc=0
+ ;;
+ path)
+ host=/
+ args=( -M 'r:|/=* r:|=*' )
+ ;;
+ ip4.addr) args=( -M 'r:|.=* r:|=*' ) ;;
+esac
+[[ -n $addhost && -n $host ]] && jails+=( "$host:$HOST" )
+
+if (( desc )); then
+ _describe -t jails jail jails "$@" "$args[@]"
+else
+ _wanted jails expl jail compadd "$@" "$args[@]" - ${jails%:*}
+fi