1999-09-06 11:16:29 +02:00
|
|
|
# Simple wrapper function for `nslookup'. With completion if you are using
|
|
|
|
# the function based completion system.
|
|
|
|
|
2000-05-09 13:56:20 +02:00
|
|
|
if [[ $argv[(I)-] -eq 0 && $argv[(I)[^-]*] -ne 0 ]]; then
|
|
|
|
command nslookup "$@"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
setopt localoptions localtraps completealiases
|
1999-09-06 11:16:29 +02:00
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
local tmp line compcontext=nslookup curcontext='nslookup:::' pmpt
|
|
|
|
local pager opager="$PAGER"
|
|
|
|
typeset +g -x PAGER=cat
|
1999-09-06 11:16:29 +02:00
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
zmodload -e zsh/zpty || zmodload -i zsh/zpty
|
1999-09-06 11:16:29 +02:00
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
trap 'return 130' INT
|
|
|
|
trap 'zpty -d nslookup' EXIT
|
1999-09-06 11:16:29 +02:00
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
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 '> ')
|
|
|
|
|
2000-05-09 13:56:20 +02:00
|
|
|
zpty nslookup nslookup "$@"
|
2000-05-05 10:52:40 +02:00
|
|
|
|
|
|
|
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
|
2000-05-05 13:10:47 +02:00
|
|
|
print -nr "$line" | eval "$pager"
|
2000-05-05 10:52:40 +02:00
|
|
|
else
|
|
|
|
print -nr "$line"
|
|
|
|
fi
|
1999-09-06 11:16:29 +02:00
|
|
|
done
|
|
|
|
|
2000-05-05 10:52:40 +02:00
|
|
|
zpty -w nslookup 'exit'
|