From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Cc: Jan Palus <jpalus@fastmail.com>
Subject: Re: zsh does not offer ssh host from config
Date: Sat, 10 Dec 2022 12:49:02 -0800 [thread overview]
Message-ID: <CAH+w=7ZV8QdT3xR3BY3aevpCcRP6qS6wsSWN8_ejK6jRd3Sj7Q@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMo=TObHF7wrt7AXt=Sf5KRUGD3tEnVyMrWqACS_k54o0A@mail.gmail.com>
On Sat, Dec 10, 2022 at 12:32 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> [...] switched to my current setup where the ssh
> config contains all remote machines (I generate it with a script). I
> really like the ability to list all machines with a TAB.
I've started using this:
zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=(
${(Mu)${(M)=history:#ssh*}:#[^/]##.*} \
${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \
/dev/null)"}%%[#| ]*}//,/ }
${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
)'
That retrieves
- all hosts mentioned in ssh commands in the current shell history
- all hosts in known_hosts and known_hosts2 (ignoring hashed hostnames)
- anything available from the local and network host configurations
My current complaint is that the hosts style is used in preference to
the my-accounts style, so I can't complete user names that are
prefixes of host names.
prev parent reply other threads:[~2022-12-10 20:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 1:06 Jan Palus
2022-12-10 12:01 ` Daniel Shahaf
2022-12-10 12:08 ` Roman Perepelitsa
2022-12-10 20:06 ` Jan Palus
2022-12-10 20:31 ` Roman Perepelitsa
2022-12-10 20:49 ` Bart Schaefer [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='CAH+w=7ZV8QdT3xR3BY3aevpCcRP6qS6wsSWN8_ejK6jRd3Sj7Q@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=jpalus@fastmail.com \
--cc=zsh-workers@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).