LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Keep bash (gnome-terminal) prompt at the top (https://www.linuxquestions.org/questions/linux-software-2/keep-bash-gnome-terminal-prompt-at-the-top-825389/)

kopatops 08-10-2010 01:19 PM

Keep bash (gnome-terminal) prompt at the top
 
Hi,

After 2 years of using bash via gnome-terminal I've decided it is annoying that the prompt/input area keeps moving after output.

Can I make it stay on top? Make all output go under that particular line like so:
_________________________________________________
Code:

[user@computer /]$ |    <-- blinking I-beam
[user@computer /]$ ls
file1.s          rwxrwxrwx
TODO            rwxrwxrwx
secret_passwords rwxrwxrwx
malicious_script rwxrwxrwx

_________________________________________________
Cheers

EDIT: I know the problem is ill-defined. I guess I just want to invert the scrolling direction. cheers

David the H. 08-11-2010 02:16 PM

I understand what you're thinking. You want a kind of separate command input box at top, with scrolling output underneath.

Well, it's possible to use ansi escape codes or tput in your PS1 or PROMPT_COMMAND to reposition the cursor at the top of the screen after each command. However, the output scrolling is a separate function, so you'd just end up positioning it inside whatever text was just printed in your last command. It wouldn't act like a "floating" box or anything.

I don't know if it's possible to directly control the scrolling behavior, either, especially not to "reverse" it. There'd be a lot of possible situations to consider, like how to treat commands that give out formatted data, or continuous streams, as well as how to deal with multi-line command input. I imagine you'd have to completely redesign the console from scratch to be sure to create the kind of split behavior you want.

MTK358 08-11-2010 02:22 PM

I doubt it's possible because the shell simply prints the prompt after the last command's output.

I guess the only good solution would be to make a terminal with a line entry on top where you enter the command and it pastes the command into the actual terminal window below when you hit enter.

kopatops 08-13-2010 07:38 AM

Thanks for your fine answers,

@MTK358: Unless I dreamt it I think I saw someone somewhere on the internet who did have that kind of behaviour in his virtual consoles (the kind you're describing). I beleive he used some sort of script, like a wrapper that read input and gave output.

He could do lots of cool stuff with it, although it was still gnome-terminal/bash under the hood.

I'll post a link if I find it (or have another vivid dream about it).

cheers

MTK358 08-13-2010 07:45 AM

Also, I don't understand why it's moving for you. Once it hits the bottom after a few commands it stays at the bottom and doesn't move!

catkin 08-13-2010 08:23 AM

Quote:

Originally Posted by kopatops (Post 4065127)
I beleive he used some sort of script, like a wrapper that read input and gave output.

Intriguing.
A function rather than a script would execute in the same shell and so have access to its settings. The $PROMPT_COMMAND variable can be used to run a command (= alias, built-in command, external command or function) after each command returns. The $BASH_COMMAND variable holds the last command executed.


All times are GMT -5. The time now is 10:44 PM.