zsh-users
 help / color / mirror / code / Atom feed
* {(t)...} usage
@ 2002-06-14 15:06 Mario Lang
  2002-06-15 21:29 ` Eric Gillespie
  2002-06-15 23:06 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Mario Lang @ 2002-06-14 15:06 UTC (permalink / raw)
  To: zsh-users

Hello.

(Please reply direct to me, I am not subscribed)

I am trying to place the hosts completion
part in my .zshrc into a zstyle -e expression.

For that, I'd like to use a unique array, and I found
the (t) flag in the manpages.

There is just no example there, and I didnt figure out how
to use it.

${(t)array-unique $(grep -v "^#" /etc/hosts) ${...some_ssh_known_hosts_too})

Is basicly what I want to do.

But the usage ot (t) is obviously wrong, it just doesnt work.

Can anyone give me an example on how to do this?


-- 
CYa,
  Mario


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: {(t)...} usage
  2002-06-14 15:06 {(t)...} usage Mario Lang
@ 2002-06-15 21:29 ` Eric Gillespie
  2002-06-15 23:06 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Gillespie @ 2002-06-15 21:29 UTC (permalink / raw)
  To: Mario Lang; +Cc: zsh-users

Mario Lang <mlang@delysid.org> writes:

> Can anyone give me an example on how to do this?

Here's how i do host completion based purely on ssh known_hosts
files.  This strips newlines and comments.

my_hosts=(${(M)${${${${(f)"$(<~/.ssh/known_hosts2)"}:#[0-9]*}%%\ *}%%,*}:#^\#})
etc_file=/etc/ssh/ssh_known_hosts2
if [[ -f $etc_file ]]; then
    etc_hosts=(${(M)${${${${(f)"$(<$etc_file)"}:#[0-9]*}%%\ *}%%,*}:#^\#})
fi
zstyle ':completion:*:*:(ping|nc|s(sh|cp)):*' hosts $etc_hosts $my_hosts

--  
Eric Gillespie <*> epg@pretzelnet.org

Conformity is a sin.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: {(t)...} usage
  2002-06-14 15:06 {(t)...} usage Mario Lang
  2002-06-15 21:29 ` Eric Gillespie
@ 2002-06-15 23:06 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2002-06-15 23:06 UTC (permalink / raw)
  To: Mario Lang, zsh-users

On Jun 14,  5:06pm, Mario Lang wrote:
} Subject: {(t)...} usage
}
} ... I'd like to use a unique array, and I found
} the (t) flag in the manpages.
} 
} There is just no example there, and I didnt figure out how
} to use it.

I'd like to know which manual you're reading, because the (t) flag has
nothing to do with unique arrays.  It reports the -type- of a parameter
("parameter" is another word for "variable" in zsh parlance).

There is a (u) flag in the 4.1.x-dev versions, but it's not available
in zsh 4.0.x or 3.anything.

However, you're on a wild goose chase.  You don't need to make the array
unique.  The completion system will take care of doing that before it
offers you any choices.

} ${(t)array-unique $(grep -v "^#" /etc/hosts) ${...some_ssh_known_hosts_too})

There is so much wrong here that I don't have time even to begin to
figure out what you actually meant, never mind explaining how to fix it.

Please read Chapter 5 <http://zsh.sunsite.dk/Guide/zshguide05.html> of
Peter Stephenson's Zsh User's Guide.  It explains many details of parameter
substitutions, with a lot of examples.

Meanwhile, if you don't mind simply pasting someone else's black magic
into your .zshrc file, the following will probably make your completion
work mostly the way you want:

zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=(
    ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \
		     /dev/null)"}%%[# ]*}//,/ }
    ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
    )'

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-15 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-14 15:06 {(t)...} usage Mario Lang
2002-06-15 21:29 ` Eric Gillespie
2002-06-15 23:06 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).