I have the following widget defined
function cdd()
{
cd /
}
zle -N cdd{,}
bindkey "^R" cdd
After pressing the key combination the cwd is already changed, but the terminal prompt is not updated. Example, after doing this ()
~/tmp/todelete$ | # press key ^R here; "~$" is the prompt; "|" denotes cursor
the terminal remains exactly unchanged. If I then type ls -ld ., it shows
~/tmp/todelete$ ls -ld .
dr-xr-xr-x 23 root root 4096 Sep 14 07:52 ./
/$ |
which means the cwd at the time ll is running is already /.
This is very confusion and may lead to serious errors. (e.g. If after pressing ^R I was interrupted to leave my desk and then come back, I might forget what I have done)
How can I let the terminal to redraw the prompt after pressing the key? Is there a zle function to do this?
reset-promptcould rescue: