11

It's really hard to explain what I am looking for exactly so I have made some example output of how I would like my terminal to behave. (each number at the start of a line represents a return on that line and > represents the input line.

>   me@computer:~$ 
5.  me@computer:~$ cat somefile                 < command
    start of file                               < output
                                                < output
    this                                        < output
    is                                          < output
    the                                         < output
    content                                     < output
    of                                          < output
    the                                         < output
    file                                        < output
                                                < output
    end of file                                 < output
4.  me@computer:~$ 
3.  me@computer:~$ 
2.  me@computer:~$ 
1.  me@computer:~$ echo this is the first line  < command
    this is the first line                      < output

in this example the input line where you type the commands that you want to execute will always be on the top. And it will push each command and it's output downwards as "events" so to speak. So if you cat a file, it won'd output everything in the reverse order, so the appearance of the output of each command is unchanged, just it's position.

3 Answers 3

3

Perhaps someone has done this (perhaps not). It would have to be done by a shell which knows how to collect the output of commands and update the screen. By itself, a regular terminal will not do this.

Supposing there were a program doing this, on each command

  • it would accept your input command (possibly multiple lines). To keep it simple, start by limiting inputs to a single line.
  • having gotten the text, the shell would run the command, collecting one line at a time from the command's standard output and error.
  • as it acquires a new line of output, it has to insert that line on the screen, pushing down the existing text. The insertion point moves down as more output is read. (Terminals provide low-level operations to help, but that's a long way from making it work).
  • if there is more output than will fit on the screen, the user likely expects the output to start scrolling up when the insertion point reaches the bottom of the screen.
  • when there is no more output (the command stops) the shell moves the cursor back to the top of the screen.

All of that is doable in a simple program. What is hard is if the command wants to take over the screen for itself. Programs which do this write — you guess it — to the standard output and the standard error. And they do not write plain text: they use escape sequences for moving around the screen.

If you limit this to the well-behaved applications which send a terminal initialization sequence, your shell could (in principle) detect this and give up for the time being, allowing the command to write to the screen. But well-behaved applications are not the majority, and you will have lots of interesting special cases to deal with.

2

This is an interesting idea, but I do not think there is anything out there that currently does this. There are many interconnected bits that have to work together to do this.

There has not been a lot attempt to change the way terminals work as they have decades of incremental history and have always worked the same basic way, drastically changing this would break allot of existing applications.

That said it would not be very hard to write a simple ncurses application to do what you want, but it would only work on basic commands, anything that expects a fully fledged terminal would fail (like vim, nano, screen, top etc). Supporting them would be a large amount of work.

However there have been a few recent attempts at creating modern terminal applications, some allow you to display images/video directly; for example terminology. The most radical of these that I have seen is black-screen which you might be interested in. It is not exactly what you are looking for and still in fairly early development (you might experience issues with it) but might give some of the same advantages to the way you want it to work (highlighting commands, making it easy to see there the output of a command starts/stops, etc).

1
0

If all that imaginary design is for helping you read the terminal more naturally, have you thought about approaching the problem the opposite way?

  • prompt always at the bottom,
  • old commands and outputs flowing upscreen.

That basically means that you reuse the original behavior of the terminal, with the only difference that you want to start the terminal with the prompt immediately pushed at the bottom.

I achieve this with these few lines in my ~/.bashrc:

__prompt_to_bottom_line() {
  tput cup $LINES
}
alias clear='clear && __prompt_to_bottom_line'

Notice that the approach you require is problematic because it requires to change the order of output lines in a non-trivial way:

  • commands have to be presented in reverse order,
  • but the outputs of each command have to presented in original order.

My approach does not suffer from this non-uniformity, exactly because all I do is pushing the prompt to the bottom since the beginning.

Essentially my screen is the tac of your screen (again, the output of a command, if multiline, is not truly taced).

You must log in to answer this question.

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