How can I clear the REPL's scrollback buffer?

I like to clear the REPL’s scrollback buffer programmatically. This helps me when running functions with long outputs, as I can easily use the scrollbar to jump to anywhere in the logs created by that function. Using CTRL-L doesn’t clear the scrollback buffer, it just puts the prompt at the top. The history is still there. It’s also not programmatic. CTRL+L doesn’t do anything in VSCode’s REPL either.

I also like to increase the max scrollback buffer size to a much larger value, so as not to lose any output from any single run.

PS: I am also logging to a file, but it’s a faster workflow to just look at it from the REPL and not bother with opening the text files (which I store at unique locations to preserve the results).

1 Like

I’m 80% this is controlled by your terminal emulator

I thought perhaps the REPL has its own history and scrollback buffer. I should check how configurable the terminal in VSCode is.

The REPL has a history, but if I remember correctly it is infinite (the history is never deleted).

There are 3 separate things here:

REPL history is stored in a file at ~/.julia/logs/repl_history.jl (for me anyway).

Max scrollback buffer is controlled by your terminal, not by Julia REPL.

Clearing the screen is done by CTRL+L as you know.

None of these actually help you with you actual question of how to clear the buffer… I think what you want is reset (not the Julia function, the bash command).

3 Likes

I think this should work. I tested reset via iTerm, which retained its scrollback history, but VSCode does not retain it. My VSCode Julia REPL is currently busy, so I can’t test it, but I imagine run(`reset`) would do. The max scrollback limit is also as you have said.

1 Like

clearconsole()