2003-02-03 12:05:53 +01:00
|
|
|
emulate -L zsh
|
|
|
|
setopt extendedglob
|
|
|
|
|
2010-07-28 16:01:12 +02:00
|
|
|
autoload -Uz read-from-minibuffer replace-string-again
|
2003-02-03 12:05:53 +01:00
|
|
|
|
|
|
|
local p1="Replace: " p2=" with: "
|
2006-10-10 13:24:38 +02:00
|
|
|
# Saving curwidget is necessary to avoid the widget name being overwritten.
|
|
|
|
local REPLY previous curwidget=$WIDGET
|
2003-02-03 12:05:53 +01:00
|
|
|
|
2005-01-13 16:31:31 +01:00
|
|
|
if (( ${+NUMERIC} )); then
|
|
|
|
(( $NUMERIC > 0 )) && previous=1
|
|
|
|
else
|
|
|
|
zstyle -t ":zle:$WIDGET" edit-previous && previous=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
read-from-minibuffer $p1 ${previous:+$_replace_string_src} || return 1
|
2008-10-29 10:57:52 +01:00
|
|
|
typeset -g _replace_string_src=$REPLY
|
2003-02-03 12:05:53 +01:00
|
|
|
|
2005-01-13 16:31:31 +01:00
|
|
|
read-from-minibuffer "$p1$_replace_string_src$p2" \
|
|
|
|
${previous:+$_replace_string_rep} || return 1
|
2008-10-29 10:57:52 +01:00
|
|
|
typeset -g _replace_string_rep=$REPLY
|
2003-02-03 12:05:53 +01:00
|
|
|
|
2006-10-10 13:24:38 +02:00
|
|
|
replace-string-again $curwidget
|