I'm trying to make a simple zsh widget that asks user for a string and sets it as the current command prompt afterwards
zle -N replace-command-buffer
bindkey '\eg' replace-command-buffer
replace-command-buffer() {
local input
echo "Enter a string: "
read -r input
BUFFER="$input"
zle reset-prompt
}
But read command returns immediately without waiting for input. How do I fix that?
Functions executed by
zlehave their standard input redirected from/dev/null, so your shell's standard input isn't available.What you probably want is to execute the
recursive-editwidget, which will setBUFFERitself.