Clear terminal output of last command only

13,890

With thanks to @rici, this behaviour can be called "folding". The output of commands isn't forgotten, but you can hide it until you need it again. Folding is common in text editors but seems to be rare in terminal emulators.

Final Term is a new terminal emulator that includes folding among many other fancy tricks. Beware: "Final Term is in heavy development and neither stable nor feature complete!" It was heavily-enough developed to fold my commands when I tested it, but too unstable not to crash. One to watch.

Share:
13,890

Related videos on Youtube

nacnudus
Author by

nacnudus

Updated on September 18, 2022

Comments

  • nacnudus
    nacnudus over 1 year

    Rather than scroll past hundreds of lines of output to see the previous command history, can the output of the last command be cleared? E.g. after executing ls, clear its output because you don't need it any more.

    EDIT:

    This is not your usual clear or ctrl+L operation. The idea is to scroll back though the history looking for the output of a previous command, but without having to have to scroll past a load of ls, or cat, or sudo apt-get install output unless I really want to. It might look something like this:

    cat fileIWantToRemember
    ls directoryIWantToForget
    # some command that wipes the output of ls
    # scroll back to see the output of cat immediately
    
    • Nullpointer42
      Nullpointer42 over 10 years
      Do you mean to clear the output, or to remove the command from your command history? If you want to modify your command history, maybe this thread addresses what you're looking for?
    • Keith
      Keith over 10 years
      The terminal just displays a stream of text, and stores some in its own internal buffer. It has no way of knowing, or discriminating between command output. The rxvt-unicode terminal does have a perl interpreter that might be able to implement something like this. But as far as I know it's not done.
    • rici
      rici over 10 years
      A long time ago, I used a terminal emulator on Mac OS X which had this feature, but I can't remember what it was called any more. It wasn't free, though. However, while doing a quick google search for it, I ran into finalterm.org, which looks like it is trying to implement that feature. However, "Final Term is in heavy development and neither stable nor feature complete!", so I didn't try it. Looks interesting, though. The google search, for what it's worth, was terminal emulator output folding
    • nacnudus
      nacnudus over 10 years
      Final Term is heavily-enough developed to fold commands (and lots of other amazing stuff), and once there's a keyboard shortcut to do that then problem solved. I was beginning to think I was crazy...
    • rici
      rici over 10 years
      @nacnudus: If you try it and it works for you, you should self-answer the question. That will provide guidance for other people with the same problem.
    • Devasish
      Devasish over 4 years
      it is not your exact answer but in such cases to view content of big files I use 'less' command instead of 'cat'. Another thing is if any command give huge number of lines as output to console you can avoid it by writing "$ the-command | less".
  • nacnudus
    nacnudus over 10 years
    See my comment to @Justin below, the point is not to have to scroll past it when looking through the history for something else. Something like HISTCONTROL=ignorespace in your second link that you can use after the fact would be good.
  • phe0113
    phe0113 over 10 years
    I'm a bit lost on what you want to achieve. Another thought, in many consoles I used, you can usually use arrow keys to browse command history in bash, does this apply to your situation?
  • nacnudus
    nacnudus over 10 years
    This seems to delete it from the history file, which is almost the right idea, but can it wipe it from the current terminal?
  • nacnudus
    nacnudus over 10 years
    Does my edit clarify the question?
  • phe0113
    phe0113 over 10 years
    @nacnudus, yes, I get your point now :)