From: Jeremy Cantrell <jmcantrell@gmail.com>
To: zsh-workers@zsh.org
Subject: patch for ssh completion
Date: Tue, 28 Feb 2017 11:17:29 -0800 [thread overview]
Message-ID: <CAHM1PU2toZMyHPPaQTkbTvctEy9qm9aLOvtMm1CVOpxWW_Wodg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 361 bytes --]
Hello!
I've found a tiny problem with the ssh completion script where any host
entries defined in included configuration files do not appear as choices
when completing. I've attached a patch that fixes it for me. Below is an
example that illustrates the problem:
~/.ssh/config:
Include hosts
~/.ssh/hosts:
Host example
HostName example.local
Thanks,
Jeremy
[-- Attachment #1.2: Type: text/html, Size: 527 bytes --]
[-- Attachment #2: zsh-ssh-host-completion.patch --]
[-- Type: text/x-patch, Size: 1204 bytes --]
--- /usr/share/zsh/functions/Completion/Unix/_ssh 2016-12-22 11:27:00.000000000 -0800
+++ packages/base/.local/share/zsh/functions/_ssh 2017-02-26 22:37:47.513422235 -0800
@@ -681,16 +681,21 @@
fi
if [[ -r $config ]]; then
local key hosts host
- while IFS=$'=\t ' read -r key hosts; do
- if [[ "$key" == (#i)host ]]; then
- for host in ${(z)hosts}; do
- case $host in
- (*[*?]*) ;;
- (*) config_hosts+=("$host") ;;
- esac
- done
- fi
- done < "$config"
+ local filename configs=($config)
+ grep '^Include\b' "$config" | sed 's/\s\+/ /g' | cut -d' ' -f2 |
+ while read -r filename; do
+ config=$HOME/.ssh/$filename
+ while IFS=$'=\t ' read -r key hosts; do
+ if [[ "$key" == (#i)host ]]; then
+ for host in ${(z)hosts}; do
+ case $host in
+ (*[*?]*) ;;
+ (*) config_hosts+=("$host") ;;
+ esac
+ done
+ fi
+ done < "$config"
+ done
if (( ${#config_hosts} )); then
_wanted hosts expl 'remote host name' \
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
next reply other threads:[~2017-03-02 3:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 19:17 Jeremy Cantrell [this message]
2017-03-02 12:12 ` Daniel Shahaf
2017-03-05 8:27 ` Daniel Shahaf
2017-03-29 23:11 ` Mark Nipper
2017-03-29 23:41 ` Daniel Shahaf
2017-03-30 15:21 ` Mark Nipper
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=CAHM1PU2toZMyHPPaQTkbTvctEy9qm9aLOvtMm1CVOpxWW_Wodg@mail.gmail.com \
--to=jmcantrell@gmail.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).