julia, julia-studio
; clear
↑ It works, equivalent to Ctrl + L , but can’t be used in automated code.
Base.run(`clear`)
↑
It doesn’t work, at least window 10, powershell.(I never checked in linux terminal)
Do you know any other way to clc(not necessary elegant or simple, whatever just works)?
1 Like
I think you want Clear
with a capital C
. See here .
Bummer. I’m not on windows right now so I can’t test things out. Hopefully someone with more expertise can help.
1 Like
Palli
September 4, 2022, 9:10pm
6
I’m not sure that’s portable.
I tracked down what Julia does on CTRL-L (and below in file is only implemented on Unix/Linux):
# Defaults
hascolor(::TextTerminal) = false
# Utility Functions
width(t::TextTerminal) = (displaysize(t)::Tuple{Int,Int})[2]
height(t::TextTerminal) = (displaysize(t)::Tuple{Int,Int})[1]
# For terminals with buffers
flush(t::TextTerminal) = nothing
clear(t::TextTerminal) = error("Unimplemented")
clear_line(t::TextTerminal, row) = error("Unimplemented")
clear_line(t::TextTerminal) = error("Unimplemented")
raw!(t::TextTerminal, raw::Bool) = error("Unimplemented")
beep(t::TextTerminal) = nothing
enable_bracketed_paste(t::TextTerminal) = nothing
disable_bracketed_paste(t::TextTerminal) = nothing
## UnixTerminal ##
Probably works too on macOS, can anyone CTRL-L on Windows (and in WSL2)?
I suppose Julia can and should support same for Windows, and could export the function for programs to use.
I use this and it works, at least on Linux. I never had a chance to test it on Windows or MacOS
import REPL
terminal = REPL.Terminals.TTYTerminal("", stdin, stdout, stderr)
REPL.Terminals.clear(terminal)
oheil:
You may try:
julia> print("\033c")
I can confirm that it works on both Windows (running Julia in Windows Terminal) and Linux (running Julia in a GNOME Terminal window).
Palli
September 4, 2022, 10:28pm
9
Great! But I believe that’s I think because Windows Terminal got “modernized” to use ancient Unix tech. If you want to support older Windows or just not with Windows Terminal, that may not apply. But going to the shell, i.e.:
julia> run(`cls`)
should always run on Windows (but not on Linux, why it would help for Juliato add it as a cross-platform option), even in PowerShell: Clear-Host (Microsoft.PowerShell.Core) - PowerShell | Microsoft Docs
Well, it works! and i totally agree with Way to clear console in julia - #9 by Palli .
oheil
September 5, 2022, 7:10am
11
I checked only on Windows, but with CMD, PowerShell and Windows-Terminal and all worked.