bash 在bash命令行上,如何删除光标前的所有字母?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12334526/
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
On bash command-line, how to delete all letters before cursor?
提问by qazwsx
On bash command-line, how to delete all letters before cursor? I know Ctrl-k deletes all afterward the cursor.
在bash命令行上,如何删除光标前的所有字母?我知道 Ctrl-k 会在光标之后删除所有内容。
回答by Mayura
Ctrl-u- Cut everything before the cursor
Ctrl-u—— Cut everything before the cursor
Other Bash shortcuts,
其他 Bash 快捷方式,
- Ctrl-a
Move cursor to beginning of line - Ctrl-e
Move cursor to end of line - Ctrl-b
Move cursor back one word - Ctrl-f
Move cursor forward one word - Ctrl-w
Cut the last word - Ctrl-k
Cut everything after the cursor - Ctrl-y
Paste the last thing to be cut - Ctrl-_
Undo
- Ctrl-a
Move cursor to beginning of line - Ctrl-e
Move cursor to end of line - Ctrl-b
Move cursor back one word - Ctrl-f
Move cursor forward one word - Ctrl-w
Cut the last word - Ctrl-k
Cut everything after the cursor - Ctrl-y
Paste the last thing to be cut - Ctrl-_
Undo
And discover more via man page for bash shell: man bash
并通过 bash shell 的手册页发现更多信息: man bash
Additional bash command-line shortcut cheat sheet: http://www.bigsmoke.us/readline/shortcuts
额外的 bash 命令行快捷方式备忘单:http: //www.bigsmoke.us/readline/shortcuts
See the documentation here: http://www.gnu.org/software/bash/manual/bashref.html#Commands-For-Killing
请参阅此处的文档:http: //www.gnu.org/software/bash/manual/bashref.html#Commands-For-Killing
Obligatory: Learn more about Bash, Linux, and Tech through Julia's comics: https://twitter.com/b0rk/media
强制性:通过 Julia 的漫画了解有关 Bash、Linux 和 Tech 的更多信息:https: //twitter.com/b0rk/media
回答by xjcl
回答by mjgpy3
The hotkey Ctrl+Ushould do this for you.
热键Ctrl+U应该为你做这件事。
回答by Saeed Alizadeh
Ctrl+x backspace clear all entry before cursor current position
Ctrl+x 退格键清除光标当前位置之前的所有条目


