Ubuntu – Terminal with output scrolling down

command line

I have currently decided to test my double monitors in the vertical configuration, and I came across a problem that I had never had before: the input line on my terminal is too far down the screen!

I was wondering if there is a way to make the output scroll downwards, so that the input line stays at the top.

e.g., a normal terminal view looks like this:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=28.3 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=46 time=13.7 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=46 time=19.1 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=45 time=20.8 ms
64 bytes from 8.8.8.8: icmp_req=5 ttl=45 time=15.6 ms
64 bytes from 8.8.8.8: icmp_req=6 ttl=46 time=15.3 ms
64 bytes from 8.8.8.8: icmp_req=7 ttl=46 time=15.3 ms
64 bytes from 8.8.8.8: icmp_req=8 ttl=45 time=14.3 ms
64 bytes from 8.8.8.8: icmp_req=9 ttl=45 time=14.3 ms
64 bytes from 8.8.8.8: icmp_req=10 ttl=45 time=15.5 ms
64 bytes from 8.8.8.8: icmp_req=11 ttl=45 time=16.9 ms
64 bytes from 8.8.8.8: icmp_req=12 ttl=45 time=16.3 ms
64 bytes from 8.8.8.8: icmp_req=13 ttl=45 time=20.0 ms
^C
--- 8.8.8.8 ping statistics ---
13 packets transmitted, 13 received, 0% packet loss, time 12017ms
rtt min/avg/max/mdev = 13.773/17.391/28.343/3.812 ms
me@my_computer:~$ 

and instead I would like to have something like this:

me@my_computer:~$ 
rtt min/avg/max/mdev = 13.773/17.391/28.343/3.812 ms
13 packets transmitted, 13 received, 0% packet loss, time 12017ms
--- 8.8.8.8 ping statistics ---
^C
64 bytes from 8.8.8.8: icmp_req=13 ttl=45 time=20.0 ms
64 bytes from 8.8.8.8: icmp_req=12 ttl=45 time=16.3 ms
64 bytes from 8.8.8.8: icmp_req=11 ttl=45 time=16.9 ms
64 bytes from 8.8.8.8: icmp_req=10 ttl=45 time=15.5 ms
64 bytes from 8.8.8.8: icmp_req=9 ttl=45 time=14.3 ms
64 bytes from 8.8.8.8: icmp_req=8 ttl=45 time=14.3 ms
64 bytes from 8.8.8.8: icmp_req=7 ttl=46 time=15.3 ms
64 bytes from 8.8.8.8: icmp_req=6 ttl=46 time=15.3 ms
64 bytes from 8.8.8.8: icmp_req=5 ttl=45 time=15.6 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=45 time=20.8 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=46 time=19.1 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=46 time=13.7 ms
64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=28.3 ms
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

I could not find any such documentation or question on the forums. If anyone has an idea, please let me know! (also if you think it's not possible)

Thanks!

PS: I'm using Ubuntu 12.04

Best Answer

I found one nice tip from which you can start. You must to play with bash:

To set it up:

$ bash    # try this in a subshell since ^C seems to cause it to exit
$ f () { sed "1s/^/$(tput cup 0 0)/;s/^/$(tput il1)/"; }
$ PROMPT_COMMAND='tput cup 0 0;tput il1; echo'
$ exec > >(f)

Press enter one extra time and it's ready to try. Sometimes the output and the prompt are out of order and there may be other weirdness, but it's kind of an interesting thing to try.

Source: Reversed Terminal / Command line window.

See also: