如果连续 returns 被击中,如何避免打印路径?

How to avoid printing path if consecutive returns are hit?

之前

host /workplace/sudo/myapp
>
host /workplace/sudo/myapp
>
host /workplace/sudo/myapp
>
host /workplace/sudo/myapp
>
host /workplace/sudo/myapp
>

期待:

>
>
>
>
host /workplace/sudo/myapp
>

我需要在 Zsh 中进行哪些具体配置才能实现此目的?

将此添加到您的 .zshrc 文件中:

PS1='%m %~
> '
autoload -Uz add-zle-hook-widget
add-zle-hook-widget line-finish remove-pwd
remove-pwd() {
  PS1='> ' zle .reset-prompt
  zle -R
}