about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-12 00:02:40 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-12 00:02:40 +0000
commit189116eac0f70862330cb9a6e49a7a85474ea7fa (patch)
tree3bbf4166b905242d6acb0ee4b90a696f16f5dd0a
parent602c2d81251d8c57dd1d0ea228dc5a3e8df68e00 (diff)
downloadzsh-189116eac0f70862330cb9a6e49a7a85474ea7fa.tar.gz
zsh-189116eac0f70862330cb9a6e49a7a85474ea7fa.tar.xz
zsh-189116eac0f70862330cb9a6e49a7a85474ea7fa.zip
zsh-workers/7779
-rw-r--r--Completion/User/_hostports9
-rw-r--r--Completion/User/_hosts4
-rw-r--r--Completion/User/_socket34
-rw-r--r--Completion/User/_telnet21
4 files changed, 66 insertions, 2 deletions
diff --git a/Completion/User/_hostports b/Completion/User/_hostports
new file mode 100644
index 000000000..9e331bb8a
--- /dev/null
+++ b/Completion/User/_hostports
@@ -0,0 +1,9 @@
+#autoload
+
+# Usage: _hostport host
+
+local host="$1"
+shift
+
+compadd "$@" - ${${(M)hosts\:#$host\:*}#*\:}
+
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index a159a9291..2ea5169cb 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -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[@]%:*}"
diff --git a/Completion/User/_socket b/Completion/User/_socket
new file mode 100644
index 000000000..353a66fd5
--- /dev/null
+++ b/Completion/User/_socket
@@ -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
diff --git a/Completion/User/_telnet b/Completion/User/_telnet
new file mode 100644
index 000000000..54d9a0a2d
--- /dev/null
+++ b/Completion/User/_telnet
@@ -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[@]" }'
+