From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: more completion stuff
Date: Thu, 9 Sep 1999 11:21:20 +0200 (MET DST) [thread overview]
Message-ID: <199909090921.LAA02526@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Clint Adams's message of Wed, 8 Sep 1999 17:29:22 -0400
Clint Adams wrote:
> > diff -u -r oldcompletion/User/_ssh Completion/User/_ssh
> > --- oldcompletion/User/_ssh Wed Sep 8 15:36:18 1999
> > +++ Completion/User/_ssh Wed Sep 8 16:15:43 1999
> > @@ -0,0 +1,152 @@
> > +#compdef ssh ssh-add ssh-agent ssh-keygen
>
> Please add slogin to this.
>
> Also, it would be nice if the construct 'user@host' were supported.
Yep, and `scp'.
This also modifies `_users' a bit: if an array names `users' exists,
we first complete only names from that array (and use `compgen -u' if
that gives no matches).
Bye
Sven
diff -u -r oldcompletion/User/_ssh Completion/User/_ssh
--- oldcompletion/User/_ssh Wed Sep 8 16:19:44 1999
+++ Completion/User/_ssh Thu Sep 9 11:18:42 1999
@@ -1,10 +1,21 @@
-#compdef ssh ssh-add ssh-agent ssh-keygen
+#compdef ssh slogin scp ssh-add ssh-agent ssh-keygen
-local state lstate line ret=1 expl
+local state lstate line ret=1 expl args
typeset -A options
+args=()
+
+# ssh-opt is a pseudo-command used to complete ssh options for `scp -o'.
+
case "$words[1]" in
-ssh)
+ssh|slogin)
+ args=(
+ ':remote host name:->userhost'
+ ':command: _command_names -e'
+ '*::args:->command'
+ )
+ ;&
+ssh-opt)
_arguments -s \
'-a[disable forwarding of authentication agent connection]' \
'-c[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' \
@@ -25,9 +36,7 @@
'-C[compress all data]' \
'-L[specify local port forwarding]:local port forwarding:->forward' \
'-R[specify remote port forwarding]:remote port forwarding:->forward' \
- ':remote host name:_hosts' \
- ':command: _command_names -e' \
- '*::args:->command' && ret=0
+ "$args[@]" && ret=0
while [[ -n "$state" ]]; do
lstate="$state"
@@ -113,11 +122,58 @@
_normal
return
;;
+ userhost)
+ if compset -P '*@'; then
+ _description expl 'remote host name'
+ _hosts "$expl[@]"
+ return
+ else
+ _description expl 'remote host name'
+ _hosts "$expl[@]" && ret=0
+ if (( ! $+options[-l] )); then
+ _description expl 'login name'
+ _users "$expl[@]" -S@ && ret=0
+ fi
+ fi
+ ;;
esac
break;
done
+ return ret
+ ;;
+scp)
+ _arguments -s \
+ '-c[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' \
+ '-P[specify port on remote host]:port number on remote host:' \
+ '-i[select identity file]:SSH identity file:_files' \
+ '-S[specify path to ssh]:path to ssh:_files -g \*\(\*\)' \
+ '-o[give SSH options]:options:->options' \
+ '-p[preserve modification times]' \
+ '-r[recursively copy directories]' \
+ '-v[verbose mode]' \
+ '-B[batch mode]' \
+ '-C[compress data]' \
+ '*:file:->file' && ret=0
+
+ if [[ "$state" = options ]]; then
+ compset -q
+ words=(ssh-opt "$words[@]" )
+ (( CURRENT++ ))
+ _ssh
+ return
+ elif [[ -n "$state" ]]; then
+ if compset -P '*:'; then
+ _files && ret=0
+ elif compset -P '*@'; then
+ _hosts -S: && ret=0
+ else
+ _files && ret=0
+ _hosts -S: && ret=0
+ _users -S@ && ret=0
+ fi
+ fi
return ret
;;
ssh-add)
diff -u -r oldcompletion/User/_users Completion/User/_users
--- oldcompletion/User/_users Wed Sep 8 16:19:43 1999
+++ Completion/User/_users Thu Sep 9 11:19:46 1999
@@ -1,6 +1,13 @@
#autoload
+# If a parameter `users' exists and it is an array, we first try to
+# complete only to its elements.
+
local expl
_description expl user
+
+[[ "${(t)users}" = *array* ]] &&
+ compadd "$expl[@]" "$@" - "$users[@]" && return 0
+
compgen "$@" "$expl[@]" -u
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-09-09 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-09 9:21 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-09-08 14:18 Sven Wischnowsky
1999-09-08 21:29 ` Clint Adams
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=199909090921.LAA02526@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).