15

If I scroll way up or use Ctrlr search and go way up in the history, how to get back down to the clear line? I know I can clear with Ctrle, Crtlu, but that modifies them. Is there an official way beside Ctrlc to reset the shell?

1 Answer 1

17

Two "official" options (from 8.4 Bindable Readline Commands in the Bash manual):

abort (C-g)
Abort the current editing command and ring the terminal’s bell (subject to the setting of bell-style).
end-of-history (M->)
Move to the end of the input history, i.e., the line currently being entered.

M-> can be entered by pressing Alt>, or Esc followed by >.

Notes:

  • abort is to be used while in the history search mode.
  • end-of-history, on the other hand, should be used after selecting a command from the history search mode (by, e.g, pressing Esc or an arrow key).
3
  • Thanks a bunch. Works a treat! Well the move to end-of-history does. The C-g doesnt but that could be because of an overriding key shortcut in Kubuntu. Konsole has a few of those (C-k). Another handy key combo is C-d to 'exit', often just exits a process and leaves you in the shell, and C-\ will kill many rogue processes and 'dump' (to somewhere). Thanks for the reference doc.
    – alchemy
    Nov 20, 2021 at 3:58
  • @alchemy Ctrl-D typically sends an EOF indicator, and Ctrl-\ sends sigquit (those are typically managed by the line discipline. You can see these settings using stty -a (e.g., askubuntu.com/a/385905/158442)
    – muru
    Nov 20, 2021 at 5:18
  • Ah, you're right about C-d being EOF, which is basically what happens when you press enter in "icanon" mode (if I understand unix.stackexchange.com/a/110248/346155). Modern terminals have their own more complex "line editors" and so C-d is a great key to replace. I use it for "intr" interupt so that I can have C-c as copy and C-x as paste. Interesting though that "icanon" mode looks like C-u used to clear the entire line instead of using C-e,C-u combo.
    – alchemy
    Nov 21, 2021 at 1:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .