From 29c11456af474a28d3d358d87b84704c123b4182 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 28 Aug 2014 10:15:28 +0200 Subject: [PATCH 1/3] virsh: make completion work with older versions of virsh Older versions of virsh doesn't have the `--name` option. Moreover when completing running domains, the title was "name domains" instead of expected "running domains". --- src/_virsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/_virsh b/src/_virsh index 119c90d..06a03a5 100644 --- a/src/_virsh +++ b/src/_virsh @@ -40,7 +40,7 @@ local -a args reply function _virsh-domains() { local -a out - out=($(virsh list "$@")) + out=( ${${${${(f)"$(virsh list "$@")"}:#(---| Id)*}## #[0-9]## ##}%% *} ) compadd -x "${${1#--}:-running} domains" -a out return $? } @@ -54,19 +54,19 @@ expand_dirs=(/$'[^\0]##\0'/ ":dir:dir name:_files -/") local -a expand_domains expand_domains=( /$'[^\0]##\0'/ - ":domains:domains:{_virsh-domains --all --name}" + ":domains:domains:{_virsh-domains --all}" ) local -a expand_domains_running expand_domains_running=( /$'[^\0]##\0'/ - ":domains:running domains:{_virsh-domains --name}" + ":domains:running domains:{_virsh-domains}" ) local -a expand_domains_inactive expand_domains_inactive=( /$'[^\0]##\0'/ - ":domains:inactive domains:{_virsh-domains --inactive --name}" + ":domains:inactive domains:{_virsh-domains --inactive}" ) local -a expand_kilobytes From 18330b0137e2fb57ffc4aae6ab519226ad948ee2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 28 Aug 2014 10:19:51 +0200 Subject: [PATCH 2/3] virsh: replace use of compadd with _describe compadd is more low-level and doesn't setup completion descriptions correctly. Notably, the description is not put in bold. --- src/_virsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_virsh b/src/_virsh index 06a03a5..9f90867 100644 --- a/src/_virsh +++ b/src/_virsh @@ -41,7 +41,7 @@ local -a args reply function _virsh-domains() { local -a out out=( ${${${${(f)"$(virsh list "$@")"}:#(---| Id)*}## #[0-9]## ##}%% *} ) - compadd -x "${${1#--}:-running} domains" -a out + _describe -t domains "${${1#--}:-running} domains" out return $? } From 1bcfd005790654c0117b61507aa32a16416bd97e Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 28 Aug 2014 16:09:06 +0200 Subject: [PATCH 3/3] virsh: inactive domains don't have an ID --- src/_virsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_virsh b/src/_virsh index 9f90867..3dee9c7 100644 --- a/src/_virsh +++ b/src/_virsh @@ -40,7 +40,7 @@ local -a args reply function _virsh-domains() { local -a out - out=( ${${${${(f)"$(virsh list "$@")"}:#(---| Id)*}## #[0-9]## ##}%% *} ) + out=( ${${${${(f)"$(virsh list "$@")"}:#(---| Id)*}## #[0-9-]## ##}%% *} ) _describe -t domains "${${1#--}:-running} domains" out return $? }