* Re: PATCH: more completion stuff
@ 1999-09-09 9:21 Sven Wischnowsky
0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-09-09 9:21 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: more completion stuff
1999-09-08 14:18 Sven Wischnowsky
@ 1999-09-08 21:29 ` Clint Adams
0 siblings, 0 replies; 3+ messages in thread
From: Clint Adams @ 1999-09-08 21:29 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH: more completion stuff
@ 1999-09-08 14:18 Sven Wischnowsky
1999-09-08 21:29 ` Clint Adams
0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 1999-09-08 14:18 UTC (permalink / raw)
To: zsh-workers
Here is an improved `_dvi', a new `_yodl', a new `_ssh', and some more
magic for `_yp'.
Bye
Sven
diff -u -r oldcompletion/User/_dvi Completion/User/_dvi
--- oldcompletion/User/_dvi Wed Sep 8 09:03:56 1999
+++ Completion/User/_dvi Wed Sep 8 14:54:23 1999
@@ -1,3 +1,95 @@
#compdef dvips dvibook dviconcat dvicopy dvidvi dviselect dvitodvi dvitype
-_files -g '*.(dvi|DVI)'
+local expl args
+
+args=(
+ '-i[specify input file]:input DVI file:_files -g \*.\(dvi\|DVI\)' \
+ '-o[specify output file]:output DVI file:_files -g \*.\(dvi\|DVI\)' \
+ ':input DVI file:_files -g \*.\(dvi\|DVI\)' \
+ ':output DVI file:_files -g \*.\(dvi\|DVI\)'
+)
+
+case "$words[1]" in
+dvips)
+ _arguments -s \
+ '-a[make three passes]' \
+ '(-B)-A[print only odd numbered pages]' \
+ '(-A)-B[print only even numbered pages]' \
+ '(-c -C)-b[select number of copies (duplicating body)]:number of copies:' \
+ '(-b -C)-c[select number of copies]:number of copies:' \
+ '(-b -c)-C[select number of copies (collated)]:number of copies:' \
+ '-d[set debug flags]:debug flags:' \
+ '(-X -Y)-D[set resolution]:resolution in dots per inch:' \
+ '-e[set maximum character offset]:maximum character offset:' \
+ '-E[generate EPSF file]' \
+ '(: -o)-f[read from stdin, write to stdout]' \
+ '-F[append control-D]' \
+ '-h[specify additional header file]:postscript header file:_files -g \*.\(\#i\)\(ps\|eps\)' \
+ '-i[one file per section]' \
+ '-k[print crop marks]' \
+ '-K[include postscript comments]' \
+ '(-pp)-l[specify last page to print]:number of last page:' \
+ '-m[specify manual feed for printer]' \
+ '-M[no automatic font generation]' \
+ '(-pp)-n[specify maximum number of pages to print]:maximum number of pages:' \
+ '-N[turn off structured comments]' \
+ '(-f)-o[specify output file name]:output file name:_files -g \*.\(\#i\)\(ps\|eps\)' \
+ '-O[specify offset of origin]:offset of origin (<x>,<y>):' \
+ '(-p -l -n)-pp[specify which pages to print]:list of pages or ranges to print:' \
+ '(-pp)-p[specify first page to print]:number of first page:' \
+ '-P[specify printer]:printer name:' \
+ '-q[quiet operation]' \
+ '-r[reverse order of pages]' \
+ '-s[enclose output in save/restore pair]' \
+ '-S[set maximum number of pages per section]:maximum number of pages per section:' \
+ '(-T)*-t[specify paper type]:paper type:(letter legal ledger a4 a3 landscape)' \
+ '(-t)-T[set paper size]:paper size (<x>,<y>):' \
+ '-x[set magnification ratio]:magnification ratio (per mille):' \
+ '(-D)-X[set horizontal resolution]:horizontal resolution:' \
+ '(-D)-Y[set vertical resolution]:vertical resolution:' \
+ '-Z[compress bitmapped fonts]' \
+ ':input file:_files -g \*.\(dvi\|DVI\)'
+ ;;
+dvibook)
+ _arguments -s \
+ '-q[quiet operation]' \
+ '-s-[specify signature size]:signature size:' \
+ "$args[@]"
+ ;;
+dviconcat)
+ _arguments \
+ '-m[specify magnification]:magnification factor:' \
+ '-o[specify output file]:output DVI file:_files -g \*.\(dvi\|DVI\)' \
+ '*:input DVI file:_files -g \*.\(dvi\|DVI\)'
+ ;;
+dvidvi)
+ _arguments -s \
+ '-q[quiet operation]' \
+ '-r[reverse order of pages]' \
+ '(-i -x)-f[select first page]:number of first page:' \
+ '(-i -x)-l[select last page]:number of last page:' \
+ '(-i -x)-n[select number of pages]:maximum number of pages:' \
+ '(-f -l -n)-i[specify included pages]:list of included pages:' \
+ '(-f -l -n)-x[specify excluded pages]:list of excluded pages:' \
+ ':input DVI file:_files -g \*.\(dvi\|DVI\)' \
+ ':output DVI file:_files -g \*.\(dvi\|DVI\)'
+ ;;
+dviselect)
+ _arguments -s \
+ '-s[silent operation]' \
+ ':list of pages:' \
+ "$args[@]"
+ ;;
+dvitodvi)
+ _arguments -s \
+ '-q[quiet operation]' \
+ '-w-[set w dimension specifier]:width for dimension specifier:' \
+ '-h-[set h dimension specifier]:height for dimension specifier:' \
+ ':page specifications:' \
+ "$args[@]"
+ ;;
+*)
+ _description expl 'DVI file'
+ _files "$expl[@]" -g '*.(dvi|DVI)'
+ ;;
+esac
diff -u -r oldcompletion/User/_rlogin Completion/User/_rlogin
--- oldcompletion/User/_rlogin Wed Sep 8 09:03:58 1999
+++ Completion/User/_rlogin Wed Sep 8 15:37:39 1999
@@ -1,4 +1,4 @@
-#compdef rlogin rsh ssh
+#compdef rlogin rsh
local expl
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
+
+local state lstate line ret=1 expl
+typeset -A options
+
+case "$words[1]" in
+ssh)
+ _arguments -s \
+ '-a[disable forwarding of authentication agent connection]' \
+ '-c[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' \
+ '-e[set escape character]:escape character (or `none'"'"'):' \
+ '(-n)-f[go to background]' \
+ '-i[select identity file]:SSH identity file:_files' \
+ '-k[disable forwarding of kerberos tickets]' \
+ '-l[specify login name]:login name:_users' \
+ '-n[redirect stdin from /dev/null]' \
+ '*-o[specify extra options]:option string:->option' \
+ '-p[specify port on remote host]:port number on remote host:' \
+ '-q[quiet operation]' \
+ '-P[use non priviledged port]' \
+ '-t[force pseudo-tty allocation]' \
+ '-v[verbose mode]' \
+ '-V[show version number]' \
+ '-x[disable X11 forwarding]' \
+ '-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
+
+ while [[ -n "$state" ]]; do
+ lstate="$state"
+ state=''
+
+ case "$lstate" in
+ option)
+ if compset -P '* '; then
+ case "$IPREFIX" in
+ *(#i)(batchmode|compression|fallbacktorsh|forward(agent|x11)|keepalive|passwordauthentication|rhosts(|rsa)authentication|rsaauthentication|usersh|kerberos(authetication|tgtparsing)|usepriviledgedport)*)
+ compadd yes no && ret=0
+ ;;
+ *(#i)cipher*)
+ _description expl 'encryption cipher'
+ compadd "$expl[@]" idea des 3des blowfish arcfour tss none && ret=0
+ ;;
+ *(#i)globalknownhostsfile*)
+ _description expl 'global file with known hosts'
+ _files "$expl[@]" && ret=0
+ ;;
+ *(#i)hostname*)
+ _description expl 'real host name to log into'
+ _hosts "$expl[@]" && ret=0
+ ;;
+ *(#i)identityfile*)
+ _description expl 'SSH identity file'
+ _files "$expl[@]" && ret=0
+ ;;
+ *(#i)(local|remote)forward*)
+ state=forward
+ ;;
+ *(#i)proxycommand*)
+ compset -q
+ shift 1 words
+ (( CURRENT-- ))
+ _normal && ret=0
+ ;;
+ *(#i)stricthostkeychecking*)
+ compadd yes no ask
+ ;;
+ *(#i)userknownhostsfile*)
+ _description expl 'user file with known hosts'
+ _files "$expl[@]" && ret=0
+ ;;
+ *(#i)user*)
+ _description expl 'user to log in as'
+ _users "$expl[@]" && ret=0
+ ;;
+ *(#i)xauthlocation*)
+ _description expl 'xauth program'
+ _files "$expl[@]" -g '*(*)' && ret=0
+ ;;
+ esac
+ else
+ _description expl 'configure file option'
+ compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S ' ' - \
+ BatchMode ClearAllForwardings Cipher Compression CompressionLevel \
+ Host ConnectionAttempts EscapeChar FallBackToRsh ForwardAgent \
+ ForwardX11 GlobalKnownHostsFile HostName IdentityFile KeepAlive \
+ KerberosAuthentication KerberosTgtPassing LocalForward \
+ NumberOfPasswordPrompts PasswordAuthentication Port ProxyCommand \
+ RemoteForward RhostsAuthentication RhostsRSAAuthentication \
+ RSAAuthentication StrictHostKeyChecking TISAuthentication \
+ UsePriviledgedPort User UserKnownHostsFile UseRsh \
+ XAuthLocation && ret=0
+ fi
+ ;;
+ forward)
+ if compset -P 1 '*:'; then
+ if compset -P '*:'; then
+ _message 'port number'
+ else
+ _hosts -S:
+ fi
+ else
+ _message 'listen-port number'
+ fi
+ return
+ ;;
+ command)
+ shift 1 words
+ (( CURRENT-- ))
+ _normal
+ return
+ ;;
+ esac
+
+ break;
+ done
+
+ return ret
+ ;;
+ssh-add)
+ _arguments -s \
+ '-p[read passphrase from stdin]' \
+ '-l[list all identities]' \
+ '-d[remove identity]' \
+ '-D[delete all identities]' \
+ '*:SSH identity file:_files'
+ return
+ ;;
+ssh-agent)
+ _arguments -s \
+ '(:)-k[kill agent automatically]' \
+ '(:)-s[force sh-style shell]' \
+ '(:)-c[force csh-style shell]' \
+ '*::command: _normal'
+ return
+ ;;
+ssh-keygen)
+ _arguments \
+ '(-p -c -u -P)-b[specify number of bits in key]:bits in key:' \
+ '(-p -c)-f[key file]:key file:_files' \
+ '(-c -u)-N[specify new passphrase]:new passphrase:' \
+ '(-b -u -f)-P[specify old passphrase]:old passphrase:' \
+ '(-p -u)-C[specify new comment]:new comment:' \
+ '(-b -f -C -u -c)-p[change passphrase of private key file]' \
+ '(-b -f -N -p -u)-c[change comment in private and public key files]' \
+ '(-b -N -C -p -c)-u[change key cipher to default]'
+ return
+ ;;
+esac
diff -u -r oldcompletion/User/_yodl Completion/User/_yodl
--- oldcompletion/User/_yodl Wed Sep 8 14:00:15 1999
+++ Completion/User/_yodl Wed Sep 8 13:59:37 1999
@@ -0,0 +1,14 @@
+#compdef -P yodl(|2*)
+
+_arguments -s \
+ '-D-[define symbol]:define symbol:' \
+ '-I-[set include directory]:include directory:_files -/' \
+ '-l-[set live data policy]:live data policy:((0\:suppress\ SYSTEM\ and\ PIPETHROUGH 1\:require\ user\ confirmation 2\:display\ macros 3\:no\ confirmation,\ no\ display))' \
+ '-o-[specify output file]:output file:_files' \
+ '-P-[specify preload command]:preload command:' \
+ '-p-[specify maximum number of passes]:maximum number of passes:' \
+ '-t[enable tracing mode]' \
+ '-v[enable verbose mode]' \
+ '-w[enable warnings]' \
+ '-h[show usage information]' \
+ '*:YODL input file:_files -g \*.\(\#i\)yodl'
diff -u -r oldcompletion/User/_yp Completion/User/_yp
--- oldcompletion/User/_yp Wed Sep 8 09:03:59 1999
+++ Completion/User/_yp Wed Sep 8 13:48:31 1999
@@ -88,7 +88,11 @@
local expl
_description expl 'map name'
- compadd "$expl[@]" - "$_yp_cache_maps[@]" && ret=0
+
+ # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'.
+
+ compadd "$expl[@]" -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \
+ "$_yp_cache_maps[@]" && ret=0
if [[ $+options[-t] -eq 0 && "$state" != maponly ]]; then
_description expl 'nicknames'
compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-09-09 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-09 9:21 PATCH: more completion stuff Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-09-08 14:18 Sven Wischnowsky
1999-09-08 21:29 ` Clint Adams
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).