mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 22:51:42 +02:00
make nslookup page it's output if too long for screen (11177)
This commit is contained in:
parent
c844ad8712
commit
d4d35a114c
2 changed files with 36 additions and 24 deletions
|
@ -1,5 +1,8 @@
|
||||||
2000-05-05 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
|
2000-05-05 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
|
||||||
|
|
||||||
|
* 11177: Functions/Misc/nslookup: make nslookup page it's output
|
||||||
|
if too long for screen
|
||||||
|
|
||||||
* Wayne: 11171: Src/builtin.c, Src/hist.c: fix for print -s when
|
* Wayne: 11171: Src/builtin.c, Src/hist.c: fix for print -s when
|
||||||
called from widget; added lines are not immediately available,
|
called from widget; added lines are not immediately available,
|
||||||
though
|
though
|
||||||
|
|
|
@ -1,34 +1,43 @@
|
||||||
# Simple wrapper function for `nslookup'. With completion if you are using
|
# Simple wrapper function for `nslookup'. With completion if you are using
|
||||||
# the function based completion system.
|
# 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
|
trap 'return 130' INT
|
||||||
pid=$!
|
trap 'zpty -d nslookup' EXIT
|
||||||
|
|
||||||
while read -pk1 char; do
|
pmpt=()
|
||||||
line="$line$char"
|
zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
|
||||||
[[ "$line" = *'
|
zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
|
||||||
> ' ]] && break
|
zstyle -s ':nslookup' pager tmp &&
|
||||||
done
|
[[ -z "$pager" ]] && pager="${opager:-more}"
|
||||||
print -nr - "$line"
|
(( $#pmpt )) || pmpt=(-p '> ')
|
||||||
|
|
||||||
line=''
|
zpty nslookup nslookup
|
||||||
while vared -p '> ' line; do
|
|
||||||
print -p "$line"
|
zpty -r nslookup line '*
|
||||||
line=''
|
> '
|
||||||
while read -pk1 char; do
|
print -nr "$line"
|
||||||
line="$line$char"
|
|
||||||
[[ "$line" = *'
|
while line=''; vared -he "$pmpt[@]" line; do
|
||||||
> ' ]] && break
|
print -s "$line"
|
||||||
done
|
[[ "$line" = exit ]] && break
|
||||||
print -nr - "$line"
|
|
||||||
line=''
|
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
|
done
|
||||||
|
|
||||||
print -p exit
|
zpty -w nslookup 'exit'
|
||||||
wait $pid
|
|
||||||
|
|
Loading…
Reference in a new issue