有时,在我决定不执行它之前,我会在控制台中输入一些shell命令。例如,我在控制台终端中键入以下内容:
sudo rm -r / # not yet committed! Thank God
嗯,我意识到它有点愚蠢,决定在真正执行之前删除。
但是,我很懒,我不想按 delete 并等待退格光标。事实是,这种情况在某种程度上对我来说是正常的。
我想用尽可能少的键盘按下来快速删除shell命令。有没有解决方案?
感谢〜
答案 0 :(得分:2)
Ctrl+u
和Ctrl+k
:
Ctrl + k # Cut the Line after the cursor to the clipboard.
Ctrl + u # Cut/delete the Line before the cursor to the clipboard.
您可能想尝试的其他常用快捷方式:
Ctrl + w # Cut the Word before the cursor to the clipboard.
Ctrl + y # Paste the last thing to be cut (yank)
Ctrl + a # Go to the beginning of the line (Home)
Ctrl + e # Go to the End of the line (End)
Alt + b # Back (left) one word
Alt + f # Forward (right) one word
Ctrl + f # Forward one character
Ctrl + b # Backward one character
Alt + d # Delete the Word after the cursor.
Ctrl + d # Delete character under the cursor
Ctrl + h # Delete character before the cursor (Backspace)
和往常一样,我建议你去Bash Keyboard Shortcuts学习更高级的Bash技能。