0

I want a keyboard shortcut that will clear everything from the terminal window, including the current line

I know that

  • Command-K clears the text to the very beginning, but if you have some text on the current line and you haven't pressed the Return key yet, Command-K preserves it.
  • Control-U clears the current line.

Is there a keyboard shortcut to do both things in a single step, or any other way to accomplish this?

0

1 Answer 1

1

If you just want to achieve this in your shell(bash/zsh), there are two ways to do this. (This guide uses bash as example)

  1. you can try binding the escape sequence that clears your screen and scroll back \e[2J\e[3J to your bash key binding, so it first sends this escape sequence, then execute unix-line-discard. For how to bind one key to two actions see here.

  2. You can, in Terminal settings, set cmd+k to send a key sequence that calls clear-display and unix-line-discard by inputing \e\C-l\C-u.

(Untested yet, may contain errors)

You must log in to answer this question.