Is there an automatically scrolling, time-delayed Unix pager command?

10

2

I'd like to view output of big commands slowed down, like a slideshow with e.g. automatic, 500ms delay between each scroll. What is the simplest way to achieve this?

Blazej Wieliczko

Posted 2012-09-10T19:55:05.750

Reputation: 103

Answers

8

A simple solution using bash:

function scroll
{
    while read -r ; do echo "$REPLY" ; sleep ${1:-0.5} ; done
}

Usage

long_command | scroll [delay]

delay is optional and defaults to 0.5.

Exit with Ctrl+C

cYrus

Posted 2012-09-10T19:55:05.750

Reputation: 18 102

1I don't know why my edit get rejected, but be warned that echo /** in your output of long_command (e.g. cat a file) will stuck and flood your terminal session if you don't put double quotes on "$REPLY". – 林果皞 – 2018-03-21T20:51:34.233

1@林果皞 approved and removed the warning, thanks. I should have added the quotes in the first place. – cYrus – 2018-03-23T13:49:09.683

... I added the warning just because system doesn't allow edit only 2 characters. – 林果皞 – 2018-03-23T13:57:22.650

4

If you can live with 1s resolution, you could do tail -n +0 -f -s <seconds>.

Nicole Hamilton

Posted 2012-09-10T19:55:05.750

Reputation: 8 987

2The output from long_command is possibly generated in less than a second so there's no point in polling for its completeness every <interval> and indeed doesn't work for me. – cYrus – 2012-09-10T22:25:58.837

2

You could use vim with an appropriate mapping to achieve this:

vim -c 'map <S-f20> L:redraw<cr>:sleep 500m<cr><C-d><S-f20>' -c 'execute "normal \<S-f20>"' -

Ctrl-d scrolls half a page at a time, replace with 10j to scroll 10 lines at a time.

Thor

Posted 2012-09-10T19:55:05.750

Reputation: 5 178