Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'clear' does not clear the scrollback buffer #268

Closed
evolbug opened this issue Jan 6, 2018 · 17 comments
Closed

'clear' does not clear the scrollback buffer #268

evolbug opened this issue Jan 6, 2018 · 17 comments

Comments

@evolbug
Copy link
Contributor

evolbug commented Jan 6, 2018

shell clear command should clear the scrollback as well.
peek 2018-01-06 15-14

@kovidgoyal
Copy link
Owner

No, it should not. clear clears only the screen.

@kovidgoyal
Copy link
Owner

To be precise clear clears the scrollback buffer only if the E3 capability is defined, which kitty does not define.

@kovidgoyal
Copy link
Owner

And just for fun, surveying terminal behavior:
Terminals that use clear to clear scrollback
xterm, linux console, putty
Terminals that use clear to clear only the screen:
kitty, konsole, urxvt, all VTE based terminals such as gnome terminal

kovidgoyal added a commit that referenced this issue Jan 6, 2018
kitty now supports using \E3J to clear the screen and scrollback buffer.
See #268
@kovidgoyal
Copy link
Owner

And with this commit, 1ef0106

you can use

printf '\E[H\E[3J'

to clear the scrollback buffer as well as the screen, if you need to.

zchee pushed a commit to zchee/kitty that referenced this issue Jan 9, 2018
kitty now supports using \E3J to clear the screen and scrollback buffer.
See kovidgoyal#268
@spl
Copy link

spl commented Sep 7, 2018

Also, since I came here looking for this and others might be interested, the following works [1, 2] to clear the screen and scrollback buffer in kitty, iTerm2, Apple Terminal, and presumably other Linux terminals (which I do not have at hand to test right now):

printf '\033[2J\033[3J\033[1;1H'

@collegeimprovements
Copy link

collegeimprovements commented Oct 9, 2019

@spl it works as expected on kitty. How can I map it with cmd+k key on mac ?
I tried map cmd+k printf '\033[2J\033[3J\033[1;1H' and map super+k send_text all printf '\033[2J\033[3J\033[1;1H' with no success :|

@OmisNomis
Copy link

@collegeimprovements - did you figure out how to map it to cmd+k?

@nkouevda
Copy link

nkouevda commented Jan 5, 2020

@collegeimprovements @OmisNomis Escape the ' and \:

map cmd+k send_text normal printf \'\\033[2J\\033[3J\\033[1;1H\'\x0d

Edit: As mentioned in #747, this also works:

map cmd+k combine : clear_terminal scrollback active : send_text normal \x0c

@OmisNomis
Copy link

@nkouevda - Thanks. Unfortunately map cmd+k combine : clear_terminal ..... has weird behaviour when text has been used (see gif below).

Escaping the ' and \ also didn't work - when using cmd+k, nothing happens.

screencast 2020-01-06 09-37-17

@YarekTyshchenko
Copy link

YarekTyshchenko commented Jul 20, 2020

So... how does one clear the scrollback (especially when looking at a running process)?
Edit: Ah, default binding of ctrl+shift+delete does what I need

@screendriver
Copy link

On macOS it's working on my machine with map ctrl+k combine : clear_terminal active : send_text normal \x0c

@YarekTyshchenko
Copy link

Hmm this is interesting: ctrl+shift+delete does clear the scrollback, but it doesn't de-allocate the ram storage. Perhaps this should be a new issue

@jpmvferreira
Copy link

On macOS it's working on my machine with map ctrl+k combine : clear_terminal active : send_text normal \x0c

It also works for me, but when I type something and then press the up key to find the previous command that starts or includes whatever I just wrote in zsh, as I usually do, it ignores whatever I write completely.

Is anybody facing this issue, and if so, how to work around it? (besides just doing a ctrl+c or typing something and running it)

@Chaitanyabsprip
Copy link

is there any way to disable scrollback buffer altogether?

@kovidgoyal
Copy link
Owner

ihttps://sw.kovidgoyal.net/kitty/conf/#opt-kitty.scrollback_lines

@pritambera2000
Copy link

pritambera2000 commented Oct 24, 2021

And with this commit, 1ef0106

you can use

printf '\E[H\E[3J'

to clear the scrollback buffer as well as the screen, if you need to.

i didn't find anything in config for this function . need help

@madhur
Copy link

madhur commented Feb 15, 2025

map ctrl+k combine : clear_terminal active : send_text normal \x0c

This does not work for me on linux. Using kitty 0.39.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests