From d4d35a114c5a776448be67089c998825a5db5422 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Fri, 5 May 2000 08:52:40 +0000 Subject: make nslookup page it's output if too long for screen (11177) --- Functions/Misc/nslookup | 59 ++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'Functions/Misc/nslookup') diff --git a/Functions/Misc/nslookup b/Functions/Misc/nslookup index 15afb2ff1..e03e55cd5 100644 --- a/Functions/Misc/nslookup +++ b/Functions/Misc/nslookup @@ -1,34 +1,43 @@ # 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 +local pager opager="$PAGER" +typeset +g -x PAGER=cat -trap 'print -p exit;return' INT +zmodload -e zsh/zpty || zmodload -i zsh/zpty -coproc command nslookup -pid=$! +trap 'return 130' INT +trap 'zpty -d nslookup' EXIT -while read -pk1 char; do - line="$line$char" - [[ "$line" = *' -> ' ]] && break -done -print -nr - "$line" - -line='' -while vared -p '> ' line; do - print -p "$line" - line='' - while read -pk1 char; do - line="$line$char" - [[ "$line" = *' -> ' ]] && break - done - print -nr - "$line" - line='' +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 nslookup + +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" | "$pager" + else + print -nr "$line" + fi done -print -p exit -wait $pid +zpty -w nslookup 'exit' -- cgit 1.4.1