У меня определен следующий виджет
function cdd()
{
cd /
}
zle -N cdd{,}
bindkey "^R" cdd
После нажатия комбинации клавиш cwd уже изменен, но подсказка терминала не обновляется. Пример, после этого ()
~/tmp/todelete$ | # press key ^R here; "~$" is the prompt; "|" denotes cursor
терминал остается без изменений. Если я затем наберу ls -ld .
, он покажет
~/tmp/todelete$ ls -ld .
dr-xr-xr-x 23 root root 4096 Sep 14 07:52 ./
/$ |
это означает, что на момент работы cwd
ll
уже является /
.
Это очень путаница и может привести к серьезным ошибкам. (например, если после нажатия ^R
меня прервали, чтобы я покинул свой стол, а затем вернулся, я мог бы забыть, что я сделал)
Как я могу позволить терминалу перерисовывать подсказку после нажатия клавиши? Есть ли для этого функция zle
?
reset-prompt
может спасти:
function cdd()
{
cd /
zle reset-prompt # XXX: added
}
reset-prompt
Force the prompts on both the left and right of the screen to be re-expanded, then redisplay the edit buffer. This reflects changes both to the prompt variables themselves and changes in the expansion of the values (for example, changes in time or directory, or changes to the value of variables referred to by the prompt).
Otherwise, the prompt is only expanded each time zle starts, and when the display as been interrupted by output from another part of the shell (such as a job notification) which causes the command line to be reprinted.
--- zshzle(1), reset-prompt, Miscellaneous, Widgets, zsh command line editor
Есть виджет (
clear-screen
) для очистки экрана и перерисовки подсказки, но я не вижу способа только перерисовать подсказку.