Is there a way to place output on the last line of the terminal, when the complete output of the application is shorter than the terminal height (e.g. just a few lines)?
My use case
I'm trying to create an application that uses an interface similar to GNU Readline-based applications
example.sh:
read -p "enter value: " value
echo "value: ${value}"
$ bash example.sh
enter value: hello
value: hello
IMHO, an important aspect of Readline's UI is that it will use the last line of the terminal, when there's enough input already before it:
I think this is important because users that regularly use Readline-based applications (like Bash or most other shells) will probably expect a prompt to be displayed on the last line of their terminal, while an output line that is followed by an empty line means the application is currently busy and not waiting for input. Example:
Another use-case would be to print something related to the input below the input line, e.g. what zsh does when the user uses the tab key to show completions:

Is there a way to place output on the last line of the terminal, when the complete output of the application is shorter than the terminal height (e.g. just a few lines)?
My use case
I'm trying to create an application that uses an interface similar to GNU Readline-based applications
example.sh:IMHO, an important aspect of Readline's UI is that it will use the last line of the terminal, when there's enough input already before it:
I think this is important because users that regularly use Readline-based applications (like
Bashor most other shells) will probably expect a prompt to be displayed on the last line of their terminal, while an output line that is followed by an empty line means the application is currently busy and not waiting for input. Example:Another use-case would be to print something related to the input below the input line, e.g. what
zshdoes when the user uses the tab key to show completions: