The easiest way to clear scrollback buffer of terminal + some deeper explanation?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
Why bother?
Clearing scrollback buffer is handy in many ways, for example, when I wish to run some command with long output, and want to quickly scroll to start of this output. When scrollback buffer is cleared, I can just scroll to top, and will be done.
Some considerations:
There is clear
command, according to man,
clear clears your screen if this is possible, including its scrollback buffer (if the extended "E3" capability is defined).
In gnome-terminal clear
does not clear scrollback buffer. (What is "E3" capability, though?)
There is also reset
, which clears, but it does a little bit more than that, and it is really slow (on my system it takes more than a second, which is significant delay for humans to be noticed).
And there is echo -ne 'ec'
or echo -ne '33c'
, which does the job. And indeed it is much faster than reset
.
The question is, what is ec
sequence, how it differs from what clear
and reset
does, and why there is no separate command for it?
There is also readline's C-l
key sequence, which by default bound to clear-screen
command (I mean, readline command, not shell command). What is this command? Which escape sequence it emits? How does it actually work? Does it run shell command? Or what? Again, in gnome-terminal, it seems like it works just by spiting out blank lines until prompt appear in top line of terminal. Not sure about other terminal emulators. This is very cumbersome behavior. It pollutes scrollback with chunks of emptiness, so you must scroll up more, and more. It is like a hack, rather than clean solution.
Another question is, is there a readline command for mentioned ec
sequence? I want to bound it to C-l
instead because I always want to clear scrollback buffer when I clear the screen.
And another question is how to just type such escape sequence into terminal, to perform desired action? Then do not have to think about binding C-l
to another readline command (if such command exists). I tried typing Esc
, then c
but this does not work.
UPDATE
This question answered mostly here: https://unix.stackexchange.com/a/375784/257159. It is very good answer which explains almost all questions asked here.
escape-characters readline terminal-emulator terminfo termcap
add a comment |Â
up vote
2
down vote
favorite
Why bother?
Clearing scrollback buffer is handy in many ways, for example, when I wish to run some command with long output, and want to quickly scroll to start of this output. When scrollback buffer is cleared, I can just scroll to top, and will be done.
Some considerations:
There is clear
command, according to man,
clear clears your screen if this is possible, including its scrollback buffer (if the extended "E3" capability is defined).
In gnome-terminal clear
does not clear scrollback buffer. (What is "E3" capability, though?)
There is also reset
, which clears, but it does a little bit more than that, and it is really slow (on my system it takes more than a second, which is significant delay for humans to be noticed).
And there is echo -ne 'ec'
or echo -ne '33c'
, which does the job. And indeed it is much faster than reset
.
The question is, what is ec
sequence, how it differs from what clear
and reset
does, and why there is no separate command for it?
There is also readline's C-l
key sequence, which by default bound to clear-screen
command (I mean, readline command, not shell command). What is this command? Which escape sequence it emits? How does it actually work? Does it run shell command? Or what? Again, in gnome-terminal, it seems like it works just by spiting out blank lines until prompt appear in top line of terminal. Not sure about other terminal emulators. This is very cumbersome behavior. It pollutes scrollback with chunks of emptiness, so you must scroll up more, and more. It is like a hack, rather than clean solution.
Another question is, is there a readline command for mentioned ec
sequence? I want to bound it to C-l
instead because I always want to clear scrollback buffer when I clear the screen.
And another question is how to just type such escape sequence into terminal, to perform desired action? Then do not have to think about binding C-l
to another readline command (if such command exists). I tried typing Esc
, then c
but this does not work.
UPDATE
This question answered mostly here: https://unix.stackexchange.com/a/375784/257159. It is very good answer which explains almost all questions asked here.
escape-characters readline terminal-emulator terminfo termcap
Please unlearn the habit of usingecho -ne
. Useprintf
instead. There are several systems whereecho -ne â¦
will literally print-ne â¦
â Fox
Dec 13 '17 at 18:39
2
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Why bother?
Clearing scrollback buffer is handy in many ways, for example, when I wish to run some command with long output, and want to quickly scroll to start of this output. When scrollback buffer is cleared, I can just scroll to top, and will be done.
Some considerations:
There is clear
command, according to man,
clear clears your screen if this is possible, including its scrollback buffer (if the extended "E3" capability is defined).
In gnome-terminal clear
does not clear scrollback buffer. (What is "E3" capability, though?)
There is also reset
, which clears, but it does a little bit more than that, and it is really slow (on my system it takes more than a second, which is significant delay for humans to be noticed).
And there is echo -ne 'ec'
or echo -ne '33c'
, which does the job. And indeed it is much faster than reset
.
The question is, what is ec
sequence, how it differs from what clear
and reset
does, and why there is no separate command for it?
There is also readline's C-l
key sequence, which by default bound to clear-screen
command (I mean, readline command, not shell command). What is this command? Which escape sequence it emits? How does it actually work? Does it run shell command? Or what? Again, in gnome-terminal, it seems like it works just by spiting out blank lines until prompt appear in top line of terminal. Not sure about other terminal emulators. This is very cumbersome behavior. It pollutes scrollback with chunks of emptiness, so you must scroll up more, and more. It is like a hack, rather than clean solution.
Another question is, is there a readline command for mentioned ec
sequence? I want to bound it to C-l
instead because I always want to clear scrollback buffer when I clear the screen.
And another question is how to just type such escape sequence into terminal, to perform desired action? Then do not have to think about binding C-l
to another readline command (if such command exists). I tried typing Esc
, then c
but this does not work.
UPDATE
This question answered mostly here: https://unix.stackexchange.com/a/375784/257159. It is very good answer which explains almost all questions asked here.
escape-characters readline terminal-emulator terminfo termcap
Why bother?
Clearing scrollback buffer is handy in many ways, for example, when I wish to run some command with long output, and want to quickly scroll to start of this output. When scrollback buffer is cleared, I can just scroll to top, and will be done.
Some considerations:
There is clear
command, according to man,
clear clears your screen if this is possible, including its scrollback buffer (if the extended "E3" capability is defined).
In gnome-terminal clear
does not clear scrollback buffer. (What is "E3" capability, though?)
There is also reset
, which clears, but it does a little bit more than that, and it is really slow (on my system it takes more than a second, which is significant delay for humans to be noticed).
And there is echo -ne 'ec'
or echo -ne '33c'
, which does the job. And indeed it is much faster than reset
.
The question is, what is ec
sequence, how it differs from what clear
and reset
does, and why there is no separate command for it?
There is also readline's C-l
key sequence, which by default bound to clear-screen
command (I mean, readline command, not shell command). What is this command? Which escape sequence it emits? How does it actually work? Does it run shell command? Or what? Again, in gnome-terminal, it seems like it works just by spiting out blank lines until prompt appear in top line of terminal. Not sure about other terminal emulators. This is very cumbersome behavior. It pollutes scrollback with chunks of emptiness, so you must scroll up more, and more. It is like a hack, rather than clean solution.
Another question is, is there a readline command for mentioned ec
sequence? I want to bound it to C-l
instead because I always want to clear scrollback buffer when I clear the screen.
And another question is how to just type such escape sequence into terminal, to perform desired action? Then do not have to think about binding C-l
to another readline command (if such command exists). I tried typing Esc
, then c
but this does not work.
UPDATE
This question answered mostly here: https://unix.stackexchange.com/a/375784/257159. It is very good answer which explains almost all questions asked here.
escape-characters readline terminal-emulator terminfo termcap
edited Dec 14 '17 at 7:18
asked Dec 13 '17 at 17:52
tosh
1142
1142
Please unlearn the habit of usingecho -ne
. Useprintf
instead. There are several systems whereecho -ne â¦
will literally print-ne â¦
â Fox
Dec 13 '17 at 18:39
2
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02
add a comment |Â
Please unlearn the habit of usingecho -ne
. Useprintf
instead. There are several systems whereecho -ne â¦
will literally print-ne â¦
â Fox
Dec 13 '17 at 18:39
2
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02
Please unlearn the habit of using
echo -ne
. Use printf
instead. There are several systems where echo -ne â¦
will literally print -ne â¦
â Fox
Dec 13 '17 at 18:39
Please unlearn the habit of using
echo -ne
. Use printf
instead. There are several systems where echo -ne â¦
will literally print -ne â¦
â Fox
Dec 13 '17 at 18:39
2
2
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
Many terminal emulators use the same escape sequences as XTerm, or similar. For XTerm, Escc is defined as "Full Reset (RIS)". It seems reasonable that a full reset would clear the scrollback buffer.
I have had no success using readline
to bind to the sequence itself, but a workaround is
bind '"C-l": "C-aC-kprintf "\033c"C-m"'
This has some caveats. First, it puts the printf
command in your shell history, which is not ideal. Second, it cannot be used while inputting a command; it overwrites the current input line.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Many terminal emulators use the same escape sequences as XTerm, or similar. For XTerm, Escc is defined as "Full Reset (RIS)". It seems reasonable that a full reset would clear the scrollback buffer.
I have had no success using readline
to bind to the sequence itself, but a workaround is
bind '"C-l": "C-aC-kprintf "\033c"C-m"'
This has some caveats. First, it puts the printf
command in your shell history, which is not ideal. Second, it cannot be used while inputting a command; it overwrites the current input line.
add a comment |Â
up vote
2
down vote
Many terminal emulators use the same escape sequences as XTerm, or similar. For XTerm, Escc is defined as "Full Reset (RIS)". It seems reasonable that a full reset would clear the scrollback buffer.
I have had no success using readline
to bind to the sequence itself, but a workaround is
bind '"C-l": "C-aC-kprintf "\033c"C-m"'
This has some caveats. First, it puts the printf
command in your shell history, which is not ideal. Second, it cannot be used while inputting a command; it overwrites the current input line.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Many terminal emulators use the same escape sequences as XTerm, or similar. For XTerm, Escc is defined as "Full Reset (RIS)". It seems reasonable that a full reset would clear the scrollback buffer.
I have had no success using readline
to bind to the sequence itself, but a workaround is
bind '"C-l": "C-aC-kprintf "\033c"C-m"'
This has some caveats. First, it puts the printf
command in your shell history, which is not ideal. Second, it cannot be used while inputting a command; it overwrites the current input line.
Many terminal emulators use the same escape sequences as XTerm, or similar. For XTerm, Escc is defined as "Full Reset (RIS)". It seems reasonable that a full reset would clear the scrollback buffer.
I have had no success using readline
to bind to the sequence itself, but a workaround is
bind '"C-l": "C-aC-kprintf "\033c"C-m"'
This has some caveats. First, it puts the printf
command in your shell history, which is not ideal. Second, it cannot be used while inputting a command; it overwrites the current input line.
answered Dec 13 '17 at 18:37
Fox
4,72111131
4,72111131
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410708%2fthe-easiest-way-to-clear-scrollback-buffer-of-terminal-some-deeper-explanation%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Please unlearn the habit of using
echo -ne
. Useprintf
instead. There are several systems whereecho -ne â¦
will literally print-ne â¦
â Fox
Dec 13 '17 at 18:39
2
This is, by my count, at least six questions in one, which is not good. There should be one question per question. Moreover, so much of the background to this question would be improved from reading what we already have that covers this, including unix.stackexchange.com/questions/87469 , unix.stackexchange.com/questions/65803 , unix.stackexchange.com/questions/335648 , unix.stackexchange.com/questions/375743 , unix.stackexchange.com/questions/10394 , and unix.stackexchange.com/questions/26975 just for starters.
â JdeBP
Dec 13 '17 at 21:02