In Windows command line (powershell and cmd), when you press Esc key while on a line, whatever you have typed at the prompt is removed.
I found that pressing Esc
key at bash prompt does nothing. Pressing Esc
and then backspace
deletes a word, but this has to be done for each word.
I am learning Bash incrementally and sometimes type something stupid in the middle of the line and feel that it is better to type from scratch again. To do this, pressing backspace
is the only way I found until now.
What do you do?
I am aware of the clear
command and Ctrl-L shortcut, but I am not talking about clearing the entire terminal. Just the line.
Best Answer
You want
kill-whole-line
, but this is not bound by default in bash.backward-kill-line
(CtrlX Backspace) andunix-line-discard
(CtrlU) both erase from the current point to the beginning of the line, so just go to the end of the line and use either.