LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-10-2010, 01:19 PM   #1
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45
Blog Entries: 1

Rep: Reputation: 16
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

Last edited by kopatops; 08-10-2010 at 01:24 PM. Reason: clarification
 
Old 08-11-2010, 02:16 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 08-11-2010, 02:22 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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.
 
Old 08-13-2010, 07:38 AM   #4
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
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
 
Old 08-13-2010, 07:45 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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!
 
Old 08-13-2010, 08:23 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by kopatops View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux Gnome Hack: Open Terminal (shell prompt) in Current / Selected Directory LXer Syndicated Linux News 0 11-06-2008 08:20 AM
Gnome Terminal: Show only current directory at prompt? extrasolar Linux - Software 5 08-01-2006 01:11 PM
bash script to resize gnome terminal ? smoker Linux - General 1 03-17-2006 03:32 PM
gnome-terminal fails to give bash prompt wfhoney Red Hat 8 04-21-2004 03:38 PM
Bash, Gnome-Terminal and Prompt Mysteries melquiades Slackware 30 11-28-2003 06:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration