How to scroll up in terminal window while new input is generated without beeing thrown back to the bottom (Linux)

37

12

In Ubuntu, I want to scroll up while a command is running in my terminal window and generates new output (actually the command running is rspec). I can scroll up, but each time rspec generates a new line of console output it throws me back down to the bottom. Is there a way to scroll all up? I'm using terminator on Linux Mint/Ubuntu 12.04 LTS

UPDATE

I found a possible workaround Terminator homepage says that with

stty ixon

you can turn on "XON/XOFF flow control for terminal output. Being able to pause output by typing ^S and resume it by typing ^Q [...]"

This it not totally what I wanted though, without having to pause the output (and maybe wondering when forgetting to turn it on again), I thought there might be a simple modifier key like shft-alt with mouse wheel scroll-up.. Any better solutions?

Yo Ludke

Posted 2013-01-24T14:09:41.887

Reputation: 485

That's one thing that I really like about LXTerminal (LXDE). – Matthew Lundberg – 2013-01-24T14:37:43.230

Are you scrolling by Shift-PgUp or by scrollbar? – ott-- – 2013-01-24T15:25:11.733

@MatthewLundberg Normally with mouse scroll wheel, so scrollbar. But it also doesn't work with shift-pgup :( Can I have lxterminal inside of terminator as well, do you know? – Yo Ludke – 2013-01-24T15:33:24.630

1xfce4-terminal has an option called Scroll on output that you can uncheck and does just what you asked. – Martín Canaval – 2013-01-24T16:16:40.153

1As a workaround, you could send the output to a file, open another terminal and tail -f file.txt to see it as it is generated. That would leave your 1st terminal free to scroll back and still let you watch the output in realtime. Not elegant I know. – terdon – 2013-01-24T17:43:43.750

Following on terdon's suggestion, there's also piping the contents to less or more as well – Dolan Antenucci – 2013-01-26T15:23:00.100

Answers

53

Although I'm a bit late, I'm posting this here so that anyone who comes here gets a solution. For me, the solution to the same problem was:

Terminator preferences -> Profiles Tab -> Scrolling [sub]tab -> Uncheck 'Scroll on output' option.

The good thing about this option, is that it will still scroll on output when you are at the very bottom of the output, but as soon as you scroll up, it will stop and won't bother you even if output content is still being generated.

I hope this helps

Chikitulfo

Posted 2013-01-24T14:09:41.887

Reputation: 726

cool :) Is it possible to create a shortcut to toggle this option? – Yo Ludke – 2013-04-05T08:14:31.110

1I've searched a bit, but haven't found any way to toggle it with a shortcut within terminator.

However, as the option is written in the terminator config file at "$HOME/.config/terminator/config", it should be possible to assign a global shortcut to a command that toggles the option on and off directly in the config file. – Chikitulfo – 2013-04-06T11:13:53.777

4Still, making that change to the config file won't affect already running terminator instances, but rather it will only affect new terminator instances launched after the edit. So if you want to toggle it on a running terminator, you have to do it manually, afaik.

In any case, with the option toggled to false, as soon as you scroll down to the last line, it continues auto scrolling on output. It only stops autoscrolling if you manually scroll up. So I don't see any real need to toggle the option on and off. – Chikitulfo – 2013-04-06T11:29:09.843

1

tail -f log.txt | less will update to advance to the new information, and you can then go up or down. You can also use less search features and so on. With the pipe method, you can also parse the moving output.

And the same idea, but without the pipe : less +F log.txt .
(This assumes you can work with your content in this fashion.)

The old Unix way was to hit Ctrl-S in your terminal to stop, and Ctrl-Q to restart output scrolling -- this is basically what terminator is letting you do with stty ixon.
With scrollbars added, this seems pretty decent to me -- hit Control-S, scroll up to whatever you like, and then Control-Q to go back down. Yes, you will occasionally forget to unpause the output.

Because I'm exceptionally lazy, and because I like the flexibility of output redirection, I'd use tail -f with the pipe (assuming that fits the case) . Then I can stop it, arrow-up and add something like a grep, and it still runs: tail -f tac_plus.log | less | egrep 'peerip'

Throw some cats and tee in there and you have a real party.

belacqua

Posted 2013-01-24T14:09:41.887

Reputation: 209

I wanted to use this for rspec spec's - The problem is, with the tail/less approaches, the colors get lost (the output is black and white instead of green/red if I run the command directly) – Yo Ludke – 2013-01-31T09:19:20.053

@YoLudke I'm not familiar with rspec or how it does colorizing. There are ways to pass colors through grep, etc., but that might not work here. Are you doing something like running pointing rspec to a persistent/looping/long-running process, and getting your output from that? – belacqua – 2013-01-31T17:58:11.263