zsh-users
 help / color / mirror / code / Atom feed
From: "Vadim A. Misbakh-Soloviov" <mva@mva.name>
To: zsh-users@zsh.org
Subject: Re: ssh host completion
Date: Sun, 25 Mar 2018 12:18:44 +0700	[thread overview]
Message-ID: <3190684.aVAqXDk5dL@note> (raw)
In-Reply-To: <CAOYnHSZUEeEqLQeC8nHzYFWEm2D5OveevgVeHqe-OR99jjuhOg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

> 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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2018-03-25  5:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28  2:13 John Benninghoff
2018-03-22  0:26 ` Oliver Kiddle
2018-03-25  4:05   ` John Benninghoff
2018-03-25  5:18     ` Vadim A. Misbakh-Soloviov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3190684.aVAqXDk5dL@note \
    --to=mva@mva.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).