Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completing from different ssh config file
- X-seq: zsh-users 10981
- From: Jean-Rene David <jrdavid@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Completing from different ssh config file
- Date: Tue, 14 Nov 2006 10:58:36 -0500
- In-reply-to: <20061114120027.0033b6aa.pws@xxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20061113172327.GC22561@princo> <20061113195712.GA21151@xxxxxxxxxxxxxxxxxx> <20061114120027.0033b6aa.pws@xxxxxxx>
* Peter Stephenson [2006.11.14 07:15]:
> Index: Completion/Unix/Command/_ssh
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
> retrieving revision 1.29
> diff -u -r1.29 _ssh
> --- Completion/Unix/Command/_ssh 3 Oct 2006 16:24:51 -0000 1.29
> +++ Completion/Unix/Command/_ssh 14 Nov 2006 11:53:15 -0000
> @@ -323,6 +323,8 @@
>
> _ssh_hosts () {
> local -a config_hosts
> + local config
> + integer ind
>
> if [[ "$IPREFIX" == *@ ]]; then
> _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
> @@ -330,7 +332,12 @@
> _combination -s '[:@]' my-accounts users-hosts \
> ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
> fi
> - if [[ -r "$HOME/.ssh/config" ]]; then
> + if (( ind = ${words[(I)-F]} )); then
> + config=$words[ind+1]
> + else
> + config="$HOME/.ssh/config"
> + fi
> + if [[ -r $config ]]; then
> local IFS=$'\t ' key hosts host
> while read key hosts; do
> if [[ "$key" == (#i)host ]]; then
> @@ -341,7 +348,7 @@
> esac
> done
> fi
> - done < "$HOME/.ssh/config"
> + done < "$config"
> if (( ${#config_hosts} )); then
> _wanted hosts expl 'remote host name' \
> compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts
Very nice. However for it to work perfectly, I had
to change the assignment to:
config=${~words[ind+1]}
In order for "~" to get expanded. Perhaps it's
safer instead of relying on globsubst to be set?
Thansk a lot!
--
JR
Messages sorted by:
Reverse Date,
Date,
Thread,
Author