4

I accidentally pressed Ctrl + L in bash (intending to do it in the browser). This caused the terminal window to scroll so that the history of commands is above the top and everything below the current command is blank.

So I scrolled it back to where the new command would be at the bottom - but as soon as I started typing, it immediately scrolled all the previous lines out of sight again.

Is there a way to undo this so it resumes behaving normally again, leaving the new typing at the bottom?

(Getting a new shell seems to do it, but I don't want to have to exit SSH and reconnect if this happens again.)

Edit: (The previous Q&A "Ctrl+L in terminal" explains what Ctrl + L does, and there are lots of answers for people wanting this effect, but I haven't found anything about reversing it.)

Note: The history is still there for reference, it's just a hassle to have to keep using the scroll bar to get a look at it.

3
  • 2
    I am not aware of anyway to undo commands in the terminal at all. Once you ran the clear command it cannot be undone.
    – Terrance
    May 1, 2018 at 20:02
  • Just copy'n'paste the part you need to see to a different window (e.g. a text editor).
    – choroba
    May 1, 2018 at 20:06
  • If you know you will need the output of a command at some point check the tee command on how to write the output to both screen and file. Once the screen is cleared you can always check the file you wrote to. Jul 12, 2021 at 21:58

1 Answer 1

1

You can just edit the .bash_history file in your home directory and delete the line with the ^L (form feed) in it.

You must log in to answer this question.

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