From: John Benninghoff <john.benninghoff@gmail.com>
To: zsh-users@zsh.org
Subject: ssh host completion (take 2)
Date: Sun, 11 Mar 2018 12:30:43 -0700 [thread overview]
Message-ID: <CAOYnHSYUFO9c3sBFG3OgedrsHKToVf2DXQcXxmfozSaZfh44GA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2573 bytes --]
[Re-sending due to email bounce although my email is in the zsh archive]
I have tried to customize ssh completion using zstyle so that it uses only
the host names configured in my ~/.ssh/config file. I use the following
section in my .zshrc file to try to get the desired behavior:
if [[ -r ~/.ssh/config ]]; then
sconf=( $(sed -n '/^Host[=\t ]/{s///;s/#.*//;p;}' ~/.ssh/config) )
zstyle ':completion::complete:ssh:argument-1:' tag-order !users
zstyle ':completion::*:ssh:*:' hosts $sconf
#zstyle -e ':completion::*:ssh:*:' hosts REPLY=$sconf
#zstyle -e ':completion::*:ssh:*:' hosts reply=$sconf
# Use ^Xh to see context and tags applicable in CLI position
fi
Some of my failed zstyle attempts are commented out. I used the first
zstyle command to eliminate the built-in users completion I didn't
want(!users). The 2nd remaining zstyle command attempts to give me
hostname completion based on hostnames in ~/.ssh/config. I know there is a
built-in ssh hostname completion based on /etc/hosts. I want to remove
that and replace it with the $sconf setting. I'm not sure how to remove
the built-in hostname completion.
*jbenninghoff@jb-mbpro 1: zstyle*
completer
:completion:* _complete _ignored
filename
:compinstall '$HOME/.zshrc'
hosts
:completion::*:ssh:*: kubeproxy pslab psnode184 ds-cluster-01
aws-ds rs1 rs-sles01 psedge ps135 psnode135 ansible dellclient dellnvme hec
lenovo-sr630 s8 l8s lenovo b143-l8seth0 t1 t2 sles4 sles3 sles2 sles medge
tag-order
:completion::complete:ssh:argument-1: !users
Strangely, zstyle shows the correct list of hostnames in hosts section but
those do not get used when I attempt completion by starting with 'ps' then
tab for example.
I get:
*jbenninghoff@jb-mbpro 1: ssh psnode4*
psnode40 psnode41 psnode42 psnode43
psnode44psnode40.ps psnode41.ps psnode42.ps psnode43.ps
psnode44.ps
Which are hostnames in /etc/hosts but not in ~/.ssh/config.
When I check the ssh completion in effect right after I type ssh by using
^Xh, I see the below output:
*jbenninghoff@jb-mbpro 1: ssh*
tags in context :completion::complete:ssh::
argument-1 options (_arguments _ssh _ssh)
tags in context :completion::complete:ssh:argument-1:
hosts users (_ssh _ssh)
hosts (_hosts _combination _ssh_hosts _ssh _ssh)
users (_users _combination _ssh_users _ssh _ssh)
jbenninghoff@jb-mbpro 1: zsh --version
zsh 5.3 (x86_64-apple-darwin17.0)
jbenninghoff@jb-mbpro 1: type -a zsh
zsh is /bin/zsh
/John
reply other threads:[~2018-03-11 19:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=CAOYnHSYUFO9c3sBFG3OgedrsHKToVf2DXQcXxmfozSaZfh44GA@mail.gmail.com \
--to=john.benninghoff@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).