From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: zsh-users@zsh.org
Subject: Ssh completion from ~/.ssh/config
Date: Tue, 7 Apr 2015 15:14:16 +0200 [thread overview]
Message-ID: <CABZhJg-8fQyOsYLHwYKoDx8DxOsReeZzfhtoi5fV_DDUQ-ziZA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1518 bytes --]
I would like to have ssh complete with hosts from my ~/.ssh/config, but I
can't get it to work. I don't know if I'm missing something obvious.
Suppose I have the following in my ssh-config:
Host myhost
HostName 192.168.1.1
User jesper
Typing "ssh <tab>" I would like it to supply "myhost".
Looking through the standard completion script _ssh, I see the following
lines:
# If users-hosts matches, we shouldn't complete anything else.
if [[ "$IPREFIX" == *@ ]]; then
_combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}"
hosts "$@" && return
else
_combination -s '[:@]' my-accounts users-hosts \
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" && return
fi
In this case the else statement is executed. Since I have not defined any
"my-accounts", the completion file _hosts is auto-loaded. This script reads
several files to find possible completions (among others /etc/hosts and
~/.ssh/known_hosts).
Since this fulfills _combination, the lines in _ssh which parse
~/.ssh/config are never executed.
If I comment out the lines I quoted above it works as I would like it to
work, but with the obvious drawback that I have modified a file that is
part of the zsh distribution, and I need to keep track of this file every
time I upgrade.
I could also specify "my-accounts" or "hosts" in my .zshrc, but then I need
to keep it in sync with my ~/.ssh/config.
Is there no way to get this to work the way I like through some
configuration that I have missed?
Jesper
next reply other threads:[~2015-04-07 13:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 13:14 Jesper Nygårds [this message]
2015-04-07 14:27 ` Vadim A. Misbakh-Soloviov
2015-04-07 15:53 ` Mikael Magnusson
2015-04-07 18:37 ` Jesper Nygårds
2015-04-08 7:24 ` shawn wilson
2015-04-08 16:47 ` Bart Schaefer
2015-04-08 17:59 ` Jesper Nygårds
2015-04-08 6:42 ` Artur Penttinen
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=CABZhJg-8fQyOsYLHwYKoDx8DxOsReeZzfhtoi5fV_DDUQ-ziZA@mail.gmail.com \
--to=jesper.nygards@gmail.com \
--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).