mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-11-19 21:44:11 +01:00
ab899b76c7
plus unposted reference to this in README plus unposted neatening of 20219 history-pattern-search
47 lines
779 B
Plaintext
47 lines
779 B
Plaintext
emulate -L zsh
|
|
setopt extendedglob
|
|
|
|
local opt keys
|
|
integer stat
|
|
|
|
while getopts "k:" opt; do
|
|
case $opt in
|
|
# Read the given number of keys. This is a bit
|
|
# ropey for more than a single key.
|
|
(k)
|
|
keys=$OPTARG
|
|
;;
|
|
|
|
(*)
|
|
return 1
|
|
;;
|
|
esac
|
|
done
|
|
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
|
|
|
|
local savelbuffer=$LBUFFER saverbuffer=$RBUFFER
|
|
local savepredisplay=$PREDISPLAY savepostdisplay=$POSTDISPLAY
|
|
|
|
LBUFFER="$2"
|
|
RBUFFER="$3"
|
|
PREDISPLAY="$PREDISPLAY$savelbuffer$saverbuffer$POSTDISPLAY
|
|
${1:-? }"
|
|
POSTDISPLAY=
|
|
|
|
if [[ -n $keys ]]; then
|
|
zle -R
|
|
read -k $keys
|
|
stat=$?
|
|
else
|
|
zle recursive-edit
|
|
stat=$?
|
|
(( stat )) || REPLY=$BUFFER
|
|
fi
|
|
|
|
LBUFFER=$savelbuffer
|
|
RBUFFER=$saverbuffer
|
|
PREDISPLAY=$savepredisplay
|
|
POSTDISPLAY=$savepostdisplay
|
|
|
|
return $stat
|