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

Re: Bug#430146: zsh: please add .ssh/config Hosts to the hosts zstyle completion



On Sat, Jun 23, 2007 at 12:33:21PM +0100, Pierre Habouzit wrote:
>   Anyways, I'm not using it anymore because I fancy the
> .ssh/known_hosts more, but I miss it :)

We could do something like this to generate matches from ~/.ssh/config .
Anyone have better ideas?

Index: Completion/Unix/Type/_hosts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_hosts,v
retrieving revision 1.10
diff -u -r1.10 _hosts
--- Completion/Unix/Type/_hosts	5 Apr 2006 10:04:32 -0000	1.10
+++ Completion/Unix/Type/_hosts	24 Jun 2007 11:52:08 -0000
@@ -48,6 +48,11 @@
         _cache_hosts+=($khosts)
       fi
     done
+
+    if zstyle -t ":completion:${curcontext}:hosts" use-ssh-config; then
+      [[ -r ~/.ssh/config ]] && _cache_hosts+=(${=${${(M)${(f)"$(<~/.ssh/config)"}:#Host*}#Host }:#*\**})
+    fi
+
   fi
 
   _hosts=( "$_cache_hosts[@]" )



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