Unix Line Discard
Type C-u
(i.e., ctrl+u) in Bash
or Zsh to discard the current line of input. To read more about it,
enter man bash
and then
type /unix-line-discard
to locate the relevant section
of the manual. Here is an excerpt:
unix-line-discard (C-u)
Kill backward from point to the beginning of the line.
The killed text is saved on the kill-ring.
Similarly, for Zsh, type man zshzle
and then
type /kill-whole-line
. We find this:
kill-whole-line (^U) (unbound) (unbound)
Kill the current line.
By the way, Emacs-style key sequence like C-a C-k
works
too.
Furthermore, it is quite likely that C-u
is mapped to
delete the current line of input in the terminal itself. To confirm
this, type the command stty -a
and check the output.
If the output contains the text kill = ^U
, then
typing C-u
anytime in the terminal would delete the
current line of input. This would happen regardless of what program
is running in the terminal. For example, programs
like cat
, sbcl
, etc. do not support key
sequences like C-a
, C-k
, C-u
,
etc. the way Bash or Zsh does. Despite this limitation,
typing C-u
in sbcl
would delete the
current line of input if the output of stty -a
indicates that the terminal has mapped this key sequence to the
operation of deleting the current line.