I need to keep the command line on the top of the screen and see the output of any command below it. How can I achieve this using any available tools on any platform?
Currently, on the all terminal emulators I have worked with if you run ls foo -l
the result will be:
$ ls foo -l
hi.txt
bye.txt
$ command prompt is here
In like to see this:
$ command prompt is here
$ ls foo -l
hi.txt
bye.txt
Best Answer
Linux, Bash.
Bash uses stderr (file descriptor
2
) to print its command prompt and command line. Usetmux
to display two shells one above the other (or just place two GUI windows, terminal emulators one above the other). In the lower one invoketty
. Don't use the lower shell directly from now on. In the upper one redirect file descriptor1
to the tty of the lower one (e.g.exec 1>/dev/pts/2
).Ctrl+L clears the upper,
clear
clears the lower. Each portion is multi-line. Thanks totmux
's features you can resize them (i.e. move the border up and down).Use this to make commands appear also in the lower portion of the display:
I tested the solution and at some point my terminal window looked like this:
(Note:
--color=auto
appeared because myls
is an alias).Expect interactive tools (like text editors) to misbehave, so it's better to revert the change while calling them. Example:
Some shells (e.g.
zsh
) use a separate file descriptor10
for command line. This allows you to redirect stderr to the lower (or yet another, 3rd) tty, keeping the command line in the upper one.