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

Re: ssh host completion



> Thanks, the first context suggestion worked.

Just in case, here is what I use for hosts completion:

  zstyle -e ':completion:*:hosts' hosts 'reply=(
    ${${${${${(f)"$(cat ${HOME}/.ssh/known_hosts 2>/dev/null)"//\[/}//\]:/ 
}:#[\|]*}%%\ *}%%,*}
    ${${${(z)${(@M)${(f)"$(cat ${HOME}/.ssh/config 2>/dev/null)"}:#Host *}
#Host }:#*[*?]*}}
    ${(s: :)${(ps:\t:)${${(f)~~"$(cat /etc/hosts 2>/dev/null)"}%%\#*}
#*[[:blank:]]}}
  )'


(I hope, you'll be able to restore lines after "78-col breakage")

Also, it is possible to avoid using "cats" by using $(<file), but it'll throw 
errors if there is no such file (and I forgot how to hide them).

Attachment: signature.asc
Description: This is a digitally signed message part.



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