3

Scenario: I'm running a bunch of commands, some of which prompt for "yes/no" answers. I accidentally type yes as a command instead of as a response to a prompt. OOPS. Now my shell looks like this:

$ yum install -y something-important
... useful output I want to go back and refer to, perhaps multiple times
$ yes
y
y
y
y
y
y
y
y
y
y
y
... there are tens of thousands of lines... oh god, Y??

I successfully halt the yes command after realizing what happened, but the damage is already done. I was in the middle of an intense shell session, and now I've lost the ability to scroll back up for relevant output! Obviously the previous text is all still there, but it's essentially inaccessible because it's dwarfed by all the y. Something like clear will help remove the unsightly y torrent from my screen, but it won't help me get back to the previous session state.

How can I rescue this session's previous output to still be useful?

New contributor
Indigenuity is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 1
    maybe get into the habit of typing y instead of yes
    – user253751
    Jun 23 at 10:02

1 Answer 1

5

Graphical terminal emulators normally have a limited number of strings to keep in the scrollback buffer, so if your previous lines have been rotated they are lost. You could increase the number of lines being kept or some terminals even allow to have an unlimited scrollback.

3
  • The statement is correct but the reason is not. The terminal emulator is not retaining the history, the shell running inside it is. Jun 22 at 22:04
  • 9
    @MarcWilson no, in this context Artem is exactly right. Shell history isn't what's being discussed here; it's terminal scrollback to see the output of commands that have been run
    – roaima
    Jun 22 at 22:05
  • 6
    While Artem is right, terminology used here is misleading as history more generally refers to the shell history of the commands you entered. Here, we're talking of terminal or terminal emulator scrollback buffer. In any case, the OP is wrong in assuming the shell has anything to do with that. Jun 23 at 5:40

Your Answer

Indigenuity is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.