Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _hosts, _hostports, _telnet and _socket
- X-seq: zsh-workers 7779
- From: Tanaka Akira <akr@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: _hosts, _hostports, _telnet and _socket
- Date: 12 Sep 1999 09:00:59 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I made `_telnet' and `_socket'. They may complete port number and
names depend on a host argument.
So I extended the format of the variable `hosts' to be able to contain
port numbers and names as:
hosts=(... host:port ...)
For that purpose, I modified `_hosts' to handle this format and made
`_hostports' to complete port numbers and names depend on a host.
Index: Completion/User/_hosts
===================================================================
RCS file: /projects/zsh/zsh/Completion/User/_hosts,v
retrieving revision 1.1.1.11
diff -u -F^( -r1.1.1.11 _hosts
--- _hosts 1999/09/06 18:36:15 1.1.1.11
+++ _hosts 1999/09/11 23:42:55
@@ -1,8 +1,8 @@
-#compdef ftp ncftp ping rwho rup xping traceroute telnet
+#compdef ftp ncftp ping rwho rup xping traceroute
local expl
: ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
_description expl host
-compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]"
+compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "${hosts[@]%:*}"
--- /dev/null Sun Sep 12 07:58:58 1999
+++ Completion/User/_hostports Sun Sep 12 08:36:42 1999
@@ -0,0 +1,9 @@
+#autoload
+
+# Usage: _hostport host
+
+local host="$1"
+shift
+
+compadd "$@" - ${${(M)hosts\:#$host\:*}#*\:}
+
--- /dev/null Sun Sep 12 07:58:58 1999
+++ Completion/User/_telnet Sun Sep 12 08:40:05 1999
@@ -0,0 +1,21 @@
+#compdef telnet
+
+_arguments -s \
+ -{F,f,x} \
+ '-8[allow 8-Bit data]' \
+ '-E[disable an escape character]' \
+ '-K[no automatic login]' \
+ '-L[allow 8-Bit data on output]' \
+ '-S+:IP type-of-service:' \
+ '-X+:authentication type to disable:' \
+ '-a[attempt automatic login]' \
+ '-c[disable .telnetrc]' \
+ '-d[debug mode]' \
+ '-e+[specify escape character]:escape character:' \
+ '-k+:realm:' \
+ '-l+[specify user]:user:' \
+ '-n+[specify tracefile]:tracefile:_files' \
+ '-r[rlogin like user interface]' \
+ ':host:_hosts' \
+ ':port:{ _hostports $line[2] "$expl[@]" }'
+
--- /dev/null Sun Sep 12 07:58:58 1999
+++ Completion/User/_socket Sun Sep 12 08:40:14 1999
@@ -0,0 +1,34 @@
+#compdef socket
+
+local state line expl
+typeset -A options
+
+_arguments -s \
+ -{b,c,f,q,r,v,w} \
+ -{s,l} \
+ '-p:command:->command' \
+ ':arg1:->arg1' \
+ ':arg2:->arg2'
+
+case "$state" in
+command)
+ compset -q
+ _normal
+ ;;
+
+arg1)
+ if (( $+options[-s] )); then
+ _message 'port'
+ else
+ _description expl 'host'
+ _hosts "$expl[@]"
+ fi
+ ;;
+
+arg2)
+ if (( ! $+options[-s] )); then
+ _description expl 'port'
+ _hostports $line[2] "$expl[@]"
+ fi
+ ;;
+esac
--
Tanaka Akira
Messages sorted by:
Reverse Date,
Date,
Thread,
Author