Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Mysterious completion of variables
- X-seq: zsh-users 9690
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: Mysterious completion of variables
- Date: Fri, 18 Nov 2005 09:38:57 -0800
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20051118114705.0bd95c76.pws@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b6c719b90511171236j5988236elda6ac5a4e9d37dc@xxxxxxxxxxxxxx> <87psoynqcv.fsf@xxxxxxxxxxxxxxxx> <20051118114705.0bd95c76.pws@xxxxxxx>
On Fri, Nov 18, 2005 at 11:47:05AM +0000, Peter Stephenson wrote:
> + if [[ "$key" == (#i)host ]]; then
> + config_hosts+=("$host")
> + fi
There's two problems with this for general use (as pointed out by Ian
himself): it puts multiple hostnames into a single completion item, and
it includes wild-carded items as hostnames. I patched the function like
this:
--- Completion/Unix/Command/_ssh 18 Nov 2005 14:53:44 -0000 1.25
+++ Completion/Unix/Command/_ssh 18 Nov 2005 17:22:39 -0000
@@ -320,10 +320,15 @@ _ssh_hosts () {
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
fi
if [[ -r "$HOME/.ssh/config" ]]; then
- local IFS=$'\t ' key host
- while read key host; do
+ local IFS=$'\t ' key hosts host
+ while read key hosts; do
if [[ "$key" == (#i)host ]]; then
- config_hosts+=("$host")
+ for host in ${(z)hosts}; do
+ case $host in
+ (*[*?]*) ;;
+ (*) config_hosts+=("$host") ;;
+ esac
+ done
fi
done < "$HOME/.ssh/config"
if (( ${#config_hosts} )); then
There may well be a non-looping way to do that, so feel free to
enlighten me if there is.
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author