Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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
5  
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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.