1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-10 12:40:58 +02:00
zsh/Functions/Zle/replace-string
Peter Stephenson 000fe2060b update to 4.3.8
2008-10-29 09:57:52 +00:00

23 lines
650 B
Text

emulate -L zsh
setopt extendedglob
autoload -U read-from-minibuffer replace-string-again
local p1="Replace: " p2=" with: "
# Saving curwidget is necessary to avoid the widget name being overwritten.
local REPLY previous curwidget=$WIDGET
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
typeset -g _replace_string_src=$REPLY
read-from-minibuffer "$p1$_replace_string_src$p2" \
${previous:+$_replace_string_rep} || return 1
typeset -g _replace_string_rep=$REPLY
replace-string-again $curwidget