about summary refs log tree commit diff
path: root/Functions/Misc/nslookup
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 13:04:04 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 13:04:04 +0000
commit3d7263ff67534b5d533c1d78eca8d648b72bca93 (patch)
treed7c3f8d1fbaf58d52b092ef241dc37db974c370d /Functions/Misc/nslookup
parentc6686513ef7eb29cbe4ed4cc27076d13b2e02ab5 (diff)
downloadzsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.tar.gz
zsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.tar.xz
zsh-3d7263ff67534b5d533c1d78eca8d648b72bca93.zip
after-move cleanup
Diffstat (limited to 'Functions/Misc/nslookup')
-rw-r--r--Functions/Misc/nslookup48
1 files changed, 48 insertions, 0 deletions
diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup
new file mode 100644
index 000000000..5b49ae9d2
--- /dev/null
+++ b/Functions/Misc/nslookup
@@ -0,0 +1,48 @@
+# Simple wrapper function for `nslookup'. With completion if you are using
+# the function based completion system.
+
+if [[ $argv[(I)-] -eq 0 && $argv[(I)[^-]*] -ne 0 ]]; then
+  command nslookup "$@"
+  return
+fi
+
+setopt localoptions localtraps completealiases
+
+local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
+local pager opager="$PAGER"
+typeset +g -x PAGER=cat
+
+zmodload -e zsh/zpty || zmodload -i zsh/zpty
+
+trap 'return 130' INT
+trap 'zpty -d nslookup' EXIT
+
+pmpt=()
+zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
+zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
+zstyle -s ':nslookup' pager tmp &&
+    [[ -z "$pager" ]] && pager="${opager:-more}"
+(( $#pmpt )) || pmpt=(-p '> ')
+
+zpty nslookup command nslookup "${(q)@}"
+
+zpty -r nslookup line '*
+> '
+print -nr "$line"
+
+while line=''; vared -he "$pmpt[@]" line; do
+  print -s "$line"
+  [[ "$line" = exit ]] && break
+
+  zpty -w nslookup "$line"
+
+  zpty -r nslookup line '*
+> '
+  if [[ -n "$pager" && ${#${(f)line}} -gt LINES ]]; then
+    print -nr "$line" | eval "$pager"
+  else
+    print -nr "$line"
+  fi
+done
+
+zpty -w nslookup 'exit'