about summary refs log tree commit diff
path: root/Functions/Misc
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Misc')
-rw-r--r--Functions/Misc/nslookup43
1 files changed, 18 insertions, 25 deletions
diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup
index d59a5e66c..8cbbdce6b 100644
--- a/Functions/Misc/nslookup
+++ b/Functions/Misc/nslookup
@@ -1,34 +1,27 @@
 # Simple wrapper function for `nslookup'. With completion if you are using
 # the function based completion system.
 
-setopt localoptions completealiases
+setopt localoptions localtraps completealiases
 
-local char line compcontext=nslookup pid
+local tmp line compcontext=nslookup curcontext=':nslookup' pmpt
 
-trap 'print -p exit;return' INT
+trap 'return 130' INT
+trap 'zpty -d nslookup' EXIT
 
-coproc command nslookup
-pid=$!
+zstyle -s ':nslookup' prompt pmpt || pmpt='> '
 
-while read -pk 1 char; do
-  line="$line$char"
-  [[ "$line" = *'
-> ' ]] && break
-done
-print -nr - "$line"
-
-line=''
-while vared -p '> ' line; do
-  print -p "$line"
-  line=''
-  while read -pk 1 char; do
-    line="$line$char"
-    [[ "$line" = *'
-> ' ]] && break
-  done
-  print -nr - "$line"
-  line=''
+zpty nslookup nslookup
+
+zpty -r nslookup line '*> '
+print -nr "$line"
+
+while line=''; vared -p "$pmpt" line; do
+  [[ "$line" = exit ]] && break
+
+  zpty -w nslookup "$line"
+
+  zpty -r nslookup line '*> '
+  print -nr "$line"
 done
 
-print -p exit
-wait $pid
+zpty -w nslookup 'exit'