Keep bash input on top line of screenExecute each command in terminal from top line / Execute clear before...
Is it possible that Curiosity measured its own methane or failed doing the spectrometry?
Language Selector
What verb goes with "coup"?
Contributing to a candidate as a Foreign National US Resident?
Has there ever been a cold war other than between the U.S. and the U.S.S.R.?
What instances can be solved today by modern solvers (pure LP)?
What does "another" mean in this case?
Term for a character that only exists to be talked to
Auto replacement of characters
Can Monks cast spells?
When do I make my first save against the Web spell?
Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?
Old story where computer expert digitally animates The Lord of the Rings
Are the plates of a battery really charged?
Which are more efficient in putting out wildfires: planes or helicopters?
How is /a/ pronounced before n/m in French?
Find the closest HTML colour name
Construction of the word подтвержда́ть
Did Snape really give Umbridge a fake Veritaserum potion that Harry later pretended to drink?
How did sloshing prevent the Apollo Service Module from moving safely away from the Command Module and how was this fixed?
Why is the saxophone not common in classical repertoire?
Will greasing clutch parts make it softer
Sleepy tired vs physically tired
How long had Bertha Mason been in the attic at the point of the events in Jane Eyre
Keep bash input on top line of screen
Execute each command in terminal from top line / Execute clear before each commandPrinting (saving) the last bash input commandIs it possible to modify the colors in bash?Bash prompt that won't clobber long commandstmux status line with blank line on top?bash script taking inputHow to always print the prompt on a new line & keep inputKeep terminal input line at the top of the terminal?Have output and input in the same window in a Bash scriptMove terminal typed input to new line when console application/script displays output textSet PS1 based on the number of jobs
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'd like to keep the bash
command prompt input at the top of the screen so that outputs from older commands are pushed downwards rather than up.
How can I achieve this?
terminal tty console stty virtual-consoles
add a comment |
I'd like to keep the bash
command prompt input at the top of the screen so that outputs from older commands are pushed downwards rather than up.
How can I achieve this?
terminal tty console stty virtual-consoles
6
So, if youcat
a file, it would be reversed order?
– chaos
Jul 25 '15 at 17:50
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
1
bash
can't do this, becausebash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows aboutbash
's interactive prompt in order know when to reset the cursor and when to scroll the window.
– chepner
Mar 15 '17 at 1:54
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago
add a comment |
I'd like to keep the bash
command prompt input at the top of the screen so that outputs from older commands are pushed downwards rather than up.
How can I achieve this?
terminal tty console stty virtual-consoles
I'd like to keep the bash
command prompt input at the top of the screen so that outputs from older commands are pushed downwards rather than up.
How can I achieve this?
terminal tty console stty virtual-consoles
terminal tty console stty virtual-consoles
edited 17 mins ago
Tom Price
asked Jul 25 '15 at 17:06
Tom PriceTom Price
687 bronze badges
687 bronze badges
6
So, if youcat
a file, it would be reversed order?
– chaos
Jul 25 '15 at 17:50
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
1
bash
can't do this, becausebash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows aboutbash
's interactive prompt in order know when to reset the cursor and when to scroll the window.
– chepner
Mar 15 '17 at 1:54
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago
add a comment |
6
So, if youcat
a file, it would be reversed order?
– chaos
Jul 25 '15 at 17:50
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
1
bash
can't do this, becausebash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows aboutbash
's interactive prompt in order know when to reset the cursor and when to scroll the window.
– chepner
Mar 15 '17 at 1:54
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago
6
6
So, if you
cat
a file, it would be reversed order?– chaos
Jul 25 '15 at 17:50
So, if you
cat
a file, it would be reversed order?– chaos
Jul 25 '15 at 17:50
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
1
1
bash
can't do this, because bash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows about bash
's interactive prompt in order know when to reset the cursor and when to scroll the window.– chepner
Mar 15 '17 at 1:54
bash
can't do this, because bash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows about bash
's interactive prompt in order know when to reset the cursor and when to scroll the window.– chepner
Mar 15 '17 at 1:54
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago
add a comment |
1 Answer
1
active
oldest
votes
Add these lines to your .bashrc
:
prompt_on_top() {
tput cup 0 0
tput el
tput el1
}
pre_cmd() {
if [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] || [ -n "$COMP_LINE" ]; then
return
fi
printf "33[2J"
}
PROMPT_COMMAND="prompt_on_top"
trap 'pre_cmd' DEBUG
bash
have PROMPT_COMMAND, which hold the command will be executed before bash
show prompt. Here we set it to function prompt_on_top
, which use tput to set the cursor at the top of screen.
bash
also have a way to execute a command before executing any command, using trap to handle signal DEBUG
. Here we set it to function pre_cmd
, which will clear old screen, and do nothing if we did completion (COMP_LINE is not empty) or run command in BASH_PROMPT
.
There's a limitation with this approach, if command output is too long too fit in a screen, then the output will be override by prompt_on_top
action. In this case, you need to pipe the output to a pager to read the whole output.
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,cat file
will showfile
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.
– psychoslave
Nov 22 '18 at 15:20
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f218323%2fkeep-bash-input-on-top-line-of-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Add these lines to your .bashrc
:
prompt_on_top() {
tput cup 0 0
tput el
tput el1
}
pre_cmd() {
if [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] || [ -n "$COMP_LINE" ]; then
return
fi
printf "33[2J"
}
PROMPT_COMMAND="prompt_on_top"
trap 'pre_cmd' DEBUG
bash
have PROMPT_COMMAND, which hold the command will be executed before bash
show prompt. Here we set it to function prompt_on_top
, which use tput to set the cursor at the top of screen.
bash
also have a way to execute a command before executing any command, using trap to handle signal DEBUG
. Here we set it to function pre_cmd
, which will clear old screen, and do nothing if we did completion (COMP_LINE is not empty) or run command in BASH_PROMPT
.
There's a limitation with this approach, if command output is too long too fit in a screen, then the output will be override by prompt_on_top
action. In this case, you need to pipe the output to a pager to read the whole output.
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,cat file
will showfile
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.
– psychoslave
Nov 22 '18 at 15:20
add a comment |
Add these lines to your .bashrc
:
prompt_on_top() {
tput cup 0 0
tput el
tput el1
}
pre_cmd() {
if [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] || [ -n "$COMP_LINE" ]; then
return
fi
printf "33[2J"
}
PROMPT_COMMAND="prompt_on_top"
trap 'pre_cmd' DEBUG
bash
have PROMPT_COMMAND, which hold the command will be executed before bash
show prompt. Here we set it to function prompt_on_top
, which use tput to set the cursor at the top of screen.
bash
also have a way to execute a command before executing any command, using trap to handle signal DEBUG
. Here we set it to function pre_cmd
, which will clear old screen, and do nothing if we did completion (COMP_LINE is not empty) or run command in BASH_PROMPT
.
There's a limitation with this approach, if command output is too long too fit in a screen, then the output will be override by prompt_on_top
action. In this case, you need to pipe the output to a pager to read the whole output.
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,cat file
will showfile
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.
– psychoslave
Nov 22 '18 at 15:20
add a comment |
Add these lines to your .bashrc
:
prompt_on_top() {
tput cup 0 0
tput el
tput el1
}
pre_cmd() {
if [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] || [ -n "$COMP_LINE" ]; then
return
fi
printf "33[2J"
}
PROMPT_COMMAND="prompt_on_top"
trap 'pre_cmd' DEBUG
bash
have PROMPT_COMMAND, which hold the command will be executed before bash
show prompt. Here we set it to function prompt_on_top
, which use tput to set the cursor at the top of screen.
bash
also have a way to execute a command before executing any command, using trap to handle signal DEBUG
. Here we set it to function pre_cmd
, which will clear old screen, and do nothing if we did completion (COMP_LINE is not empty) or run command in BASH_PROMPT
.
There's a limitation with this approach, if command output is too long too fit in a screen, then the output will be override by prompt_on_top
action. In this case, you need to pipe the output to a pager to read the whole output.
Add these lines to your .bashrc
:
prompt_on_top() {
tput cup 0 0
tput el
tput el1
}
pre_cmd() {
if [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] || [ -n "$COMP_LINE" ]; then
return
fi
printf "33[2J"
}
PROMPT_COMMAND="prompt_on_top"
trap 'pre_cmd' DEBUG
bash
have PROMPT_COMMAND, which hold the command will be executed before bash
show prompt. Here we set it to function prompt_on_top
, which use tput to set the cursor at the top of screen.
bash
also have a way to execute a command before executing any command, using trap to handle signal DEBUG
. Here we set it to function pre_cmd
, which will clear old screen, and do nothing if we did completion (COMP_LINE is not empty) or run command in BASH_PROMPT
.
There's a limitation with this approach, if command output is too long too fit in a screen, then the output will be override by prompt_on_top
action. In this case, you need to pipe the output to a pager to read the whole output.
edited Jul 26 '15 at 5:10
answered Jul 25 '15 at 17:45
cuonglmcuonglm
108k26 gold badges221 silver badges322 bronze badges
108k26 gold badges221 silver badges322 bronze badges
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,cat file
will showfile
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.
– psychoslave
Nov 22 '18 at 15:20
add a comment |
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,cat file
will showfile
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.
– psychoslave
Nov 22 '18 at 15:20
1
1
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
Thanks for your well explained answer, there's a lot for me to read up on and learn. I've tested your script, and currently it effectively wipes the old output from the screen between commands. I'd like to keep the previous outputs on the screen, below the prompt, and have it so that new outputs are inserted between the prompt and the old output, therefore pushing the old output down the screen.
– Tom Price
Jul 26 '15 at 13:28
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
For those coming here via a web search, this code github.com/swirepe/alwaysontop also "keeps your bash prompt at the top of the screen", plus a couple of other functions. Does not answer the original question though: older command outputs are deleted as with cuonglm's code.
– WillC
Aug 1 '18 at 18:39
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,
cat file
will show file
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.– psychoslave
Nov 22 '18 at 15:20
An other drawback of this solution, is that you don't have feedback on what command was last executed. That is,
cat file
will show file
content, but you don't get an immediate feedback of the exact command executed. Ideally the prompt would be followed with an non-expanded + expanded version of the executed command, followed with the std ouput.– psychoslave
Nov 22 '18 at 15:20
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f218323%2fkeep-bash-input-on-top-line-of-screen%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
So, if you
cat
a file, it would be reversed order?– chaos
Jul 25 '15 at 17:50
Nope, but I'd want the chunks of output to be pushed downwards
– Tom Price
Jul 26 '15 at 9:45
1
bash
can't do this, becausebash
doesn't even know about screen positions: it just writes to an output file. You would need a terminal emulator that knows aboutbash
's interactive prompt in order know when to reset the cursor and when to scroll the window.– chepner
Mar 15 '17 at 1:54
Thanks @chepner, I'm revisiting this problem and your comment made me look outside of bash and start looking at the whole display stack. I want to remain within the text-based virtual consoles (i.e. no X Windows) so I'd be avoiding terminal emulators for now, but for my GUI sessions I'll certainly look into that. In case anyone comes across this question, my guess is it's to do with tty and I'm currently looking here for inspiration... linusakesson.net/programming/tty
– Tom Price
12 mins ago