Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh does not offer ssh host from config
- X-seq: zsh-workers 51181
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Jan Palus <jpalus@xxxxxxxxxxxx>
- Subject: Re: zsh does not offer ssh host from config
- Date: Sat, 10 Dec 2022 12:49:02 -0800
- Archived-at: <https://zsh.org/workers/51181>
- In-reply-to: <CAN=4vMo=TObHF7wrt7AXt=Sf5KRUGD3tEnVyMrWqACS_k54o0A@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <20221209010650.sq2cp5a2op2mrpat@pine.grzadka> <CAN=4vMrpAh7ChTOobqhvE6ioNiWVr40+juSQaKe48OVZsYOjrg@mail.gmail.com> <20221210200602.ayy4d3yzd6vz52qc@pine.grzadka> <CAN=4vMo=TObHF7wrt7AXt=Sf5KRUGD3tEnVyMrWqACS_k54o0A@mail.gmail.com>
On Sat, Dec 10, 2022 at 12:32 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author