Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [newbie] bash-like feature - autocompletion problem

> I have switched to zsh with the installation of a freebsd workstation @ home; 
> among others, I have the following problem:
> on my linux machine (bash-2.5) I have added one entry in /etc/hosts stating 
> host1 - which helped me when ssh-ing (just typing ssh root@h[TAB] 
> and I got the host1 completed)
> here, using zsh, I tried to do the same, but I get something like:
> [petre@kgb]$ more /etc/hosts | grep cockeru                                   
>          cockeru
> [petre@kgb]$ ssh root@coc                                                     
> No matches for: `remote host name', `host', or `corrections'
> I'm using
> [petre@kgb]$ zsh --version                                                    
> zsh 4.0.6 (i386-portbld-freebsd4.7)
> where and what should I modify ?

Here's a little fragment of my .zshrc:

    zstyle ':completion:*' hosts `\
      [[ -f ~/.hosts ]] &&
        sed 's/ .*$//' < ~/.hosts;
      [[ -f ~/.rhosts ]] &&
        sed 's/ .*$//' < ~/.rhosts`

The whole bit between the `...` is just a sed script which grabs
hostnames from various files.  The newer (non-compctl) zsh completion
system seems to make use of a style.  If you don't set that style with a
zstyle command, zsh can't guess what your hosts are.  It seems that zsh
doesn't pick any files by default for a list of hostnames.

I'd say that in your situation you'd want to do something like

    zstyle ':completion:*' hosts `cat /etc/hosts`

(or fancier versions which I'm sure others here will suggest that don't
use cat or sed) in your .zshrc.

Let me know how it goes.

Debbie Pickett http://www.csse.monash.edu.au/~debbiep debbiep@xxxxxxxxxxxxxxxxxx
 "Beaujolais goes straight to my head, beaujolais puts me to shame, And I don't
  know why I'm in this place or how I came." - _Beaujolais_, The Alan Parsons

Messages sorted by: Reverse Date, Date, Thread, Author