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?