1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 21:44:11 +01:00
zsh/Functions/Misc/nslookup

49 lines
1.1 KiB
Plaintext
Raw Normal View History

1999-09-06 11:16:29 +02:00
# 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
1999-09-06 11:16:29 +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
zmodload -e zsh/zpty || zmodload -i zsh/zpty
1999-09-06 11:16:29 +02:00
trap 'return 130' INT
trap 'zpty -d nslookup' EXIT
1999-09-06 11:16:29 +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 '> ')
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" | eval "$pager"
else
print -nr "$line"
fi
1999-09-06 11:16:29 +02:00
done
zpty -w nslookup 'exit'