Zsh 中的哪个快捷方式与 Bash 中的 Ctrl-U 相同?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3483604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which shortcut in Zsh does the same as Ctrl-U in Bash?
提问by Kent
In Bash, when I am typing a command, I press Ctrl+U, all characters from the beginning of the line to the cursor are going to be removed. However, in zsh, if I pressed Ctrl+U, the whole line is gone.
在 Bash 中,当我输入命令时,按Ctrl+ U,从行首到光标的所有字符都将被删除。但是,在 zsh 中,如果我按Ctrl+ U,则整行都消失了。
How to do the same in Zsh as in Bash?
如何在 Zsh 中做与在 Bash 中相同的事情?
回答by Gilles 'SO- stop being evil'
It sounds like you'd like for Ctrl+Uto be bound to backward-kill-linerather than kill-whole-line, so add this to your .zshrc:
听起来您希望将Ctrl+U绑定到backward-kill-line而不是kill-whole-line,因此将其添加到您的.zshrc:
bindkey \^U backward-kill-line
The bindkeybuiltin and the available editing commands (“widgets”) are documented in the zshzleman page.
在bindkey内置和可编辑命令(“部件”)都记录在zshzle手册页。

