about summary refs log tree commit diff
path: root/Completion/User/_socket
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_socket')
-rw-r--r--Completion/User/_socket34
1 files changed, 34 insertions, 0 deletions
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