Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It occurred to me recently that it would occasionally be much better to type terminal/command line commands at the top of a window, with the last run commands below. The reverse of the usual display.

On smaller laptop screens for example, it's much more comfortable to focus at the top of the screen, than at the bottom.

Regardless of wether this is a good idea or not, does such a terminal / command line plugin exist for achieving this?

(I'm mostly OS X based, but interested in all platform solutions)

share|improve this question
Multi-line output would be really awkward to read. – Daniel Beck Nov 10 '10 at 16:18
@Daniel Beck, I suppose that could still go top to bottom - just below my current line..... but i see your point, it wouldn't just be a simple 'reverse all'. – Jon Hadley Nov 10 '10 at 16:29
Right, and after it's filled a page you need to scroll back up to see the current (not the previous) prompt. That's the really awkward behaviour, not the highway line order alternative. – Daniel Beck Nov 10 '10 at 16:50
+1 for xkcd link ;) – Jon Hadley Nov 10 '10 at 16:54
up vote 2 down vote accepted

Here's something to play with in 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.

Screen oriented programs won't work because they don't see a tty.

share|improve this answer
tput cup 0 0 homes the cursor to the upper left of the terminal. tput il1 inserts an empty line. The sed command inserts those control sequences at the beginning, respectively, of the first line and each line of output redirected to the function. The exec command redirects all stdout to the function. The PROMPT_COMMAND is executed each time a Bash prompt is issued and causes the prompt to be displayed at the top of the terminal. – Dennis Williamson Nov 11 '10 at 12:00
Another approach might be to use Bash's DEBUG trap to issue the cursor movement sequences. – Dennis Williamson Feb 16 '11 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .