I have large output from a python script that clear the terminal and print again, but the scrollbar of terminal always is in the bottom. screenshot showing long output

Is it possible to fix the scrollbar to the top so I could always see the beginning of the output like this:

Image 2

I need the terminal to be continuously updating but it shouldn't scroll down to the end, I need to always see the top of the output even while it is updating.

Command example:

enter image description here

  • 3
    Simply due to how terminal is implemented, it's always going to scroll down to the bottom and the last lines/characters. So always keeping first few lines on screen may be possible but it cuts against how terminals actually work and may be difficult to implement. Use less or more or another pager software as terdon's answer suggests. – Sergiy Kolodyazhnyy Dec 18 '18 at 0:40

It sounds like you just want to use a pager like less or more:

$ seq 1 1000 | less

You can scroll up and down with the arrow keys and, when you've finished, hit q to exit. You can also search using /. See man less for details.

Alternatively, you can use head to only see the first few lines. For example

$ seq 1 1000 | head
  • Thanks for you answer, but the problem is that the script always is update the terminal so this process never end. I can't run "seq python script.py | head". What I want is for the terminal to continue updating is to be able to see always up and also thanks for the grammar corrections. – sebastian morales Dec 18 '18 at 0:41
  • 1
    @sebastianmorales This information should be part of the question. Please click "edit" button under your question and add this. Otherwise question is incomplete and unclear. – Sergiy Kolodyazhnyy Dec 18 '18 at 0:45
  • @SergiyKolodyazhnyy I do it. Ty – sebastian morales Dec 18 '18 at 0:48
  • 1
    @sebastianmorales it would also help if you could give an example of a specific command you use that does this. I can't think of any tool that behaves as you describe but which doesn't already do this buffering for you. For example, top will continuously update without scrolling down, but it is designed that way. – terdon Dec 18 '18 at 0:53
  • @terdon I add a image in the body question with a small table, what I want to see is the header like block the scrollbar on the top. – sebastian morales Dec 18 '18 at 1:03

There's an option in GNOME Terminal's Profile Preferences: Scroll on output. By default it's unchecked, and the effect is that, when a command is producing continuous output, and you scroll up at least once, then the terminal will not automatically scroll down to the latest line of output.

Unfortunately, you still do need to scroll up once when the output starts to trigger this behaviour. If that's not workable, using a pager like less is the best option.

  • I had already activated this option, but it did not work. How can I use less with "python script.py"? – sebastian morales Dec 18 '18 at 0:46
  • @sebastianmorales if you check that output, then the terminal will always jump to the last line. You should leave it unchecked and scroll when the output starts. As for less, that's in terdon's answer. – muru Dec 18 '18 at 0:48

Your Answer

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.