From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4748 invoked by alias); 11 Mar 2018 19:30:51 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23231 Received: (qmail 8049 invoked by uid 1010); 11 Mar 2018 19:30:51 -0000 X-Qmail-Scanner-Diagnostics: from mail-lf0-f46.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.215.46):SA:0(-1.9/5.0):. Processed in 2.307125 secs); 11 Mar 2018 19:30:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: john.benninghoff@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=gJ1DOsnGL/hCek/QNzoR9IOGR/MX0M6mxeyxHdhO3pk=; b=JLo4V0kJ9bMPwFjyC30BmQq1aEaPfWvaCzOF7kvWQHlGjJRqVhYKurONeqU51vKKPM h+63vwRYonZiYcCyKKo7S/uPxi+bh7NCQDlNFJ71LBJjW3KX8qLTNs13kbMpCIetmxaW xH0j0ugZFY7Ar3hgV3DThRgTwJ+eFU+o38O7tnlbG/J/yzPTiFhOa2JXh/34rbTCG0aE 922n7WdHN0see7RLfmISrfvIRHlft453nEQ61Th7C+8sh5jeTxgRoU735zGVt30GzGeF TcrqubiWLN6P5TCsSi39Yd+DbEsgpEB4vvPcp7uLNIqyOKxywxUJd9mFy6PqvqGFg9Y1 f3XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gJ1DOsnGL/hCek/QNzoR9IOGR/MX0M6mxeyxHdhO3pk=; b=Ai2Ba/3E9jM6qvBsIqHTfX+VfVIiHFguvlStrZK5XgXIGJgOGzaTtn2RhM+eoAYCeZ TzHrsJMBuhzcZNoUEf4wVT41FGulsn0sSW/cvN0cLYt8NYlyHHYqOriK+RmsNE/iF94N s7cQkZ2E/fr5KOYgC6TMBQD1IbscVUI8P/7+Dz0dwUYfLrsY+nf6hhlqC3a7QqP1Z+UO J6/kKdlmMLzoRaB4ZSkcYAV2Z79k4rZ97P75yZrv5m+sAZnP8caZ8cCasHuQZi2cEtR3 7RI2IhlqzKX2p9scnJ5GafcZO+tp9iglTvaHOMnVUNsqpUYBl3G1d8q2eTTI6mPSHtyl YQQA== X-Gm-Message-State: AElRT7FkHuv9baNU6Ygw5S4/BFpPV/Q+7DKwdCQKwPipixD8jjDOTpZY m2JJg971IjWu4ckRVQMgKHyptUnfBI6OqJunZ7Ymrg== X-Google-Smtp-Source: AG47ELtpEzpvsTR7CVhwJl5MCueBkrGUSo6uVVB4gIcnJKyz6iGnqJmVzhC89ZhaTj90UMawe/ATrA6s3qL+zjZL6GI= X-Received: by 10.46.83.87 with SMTP id t23mr3653296ljd.38.1520796643804; Sun, 11 Mar 2018 12:30:43 -0700 (PDT) MIME-Version: 1.0 From: John Benninghoff Date: Sun, 11 Mar 2018 12:30:43 -0700 Message-ID: Subject: ssh host completion (take 2) To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="94eb2c1cf93cbaca880567280f21" --94eb2c1cf93cbaca880567280f21 Content-Type: text/plain; charset="UTF-8" [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 --94eb2c1cf93cbaca880567280f21--