Just_Alex
Just_Alex

Reputation: 558

Julia: How to clear console

I am using Julia Studio and would like to know the command for clearing the console of text and memory like imports or variables? Something like matlabs "clc" and "clear" commands.

Upvotes: 27

Views: 31111

Answers (4)

Deye Gvwargiya
Deye Gvwargiya

Reputation: 21

can try this:

function clc()
    if Sys.iswindows()
        return read(run(`powershell cls`), String)
    elseif Sys.isunix()
        return read(run(`clear`), String)
    elseif Sys.islinux()
        return read(run(`printf "\033c"`), String)
    end
end

use like:

clc();

Upvotes: 2

Joseph S
Joseph S

Reputation: 330

To clear Julia REPL, press Ctrl + L.

Upvotes: 17

Jake Ireland
Jake Ireland

Reputation: 652

To clear the console, you can go into the shell and run clear (or cls) from there:

julia> ;
shell> clear

Upvotes: 21

Qni
Qni

Reputation: 76

As mentioned workspace() provides a fresh Main. One can clear variables (and the screen) with the following:


function clear()
    Base.run(`clear`)
    for var in names(Main)
        try
            eval(parse("$var=0"))
        catch e
        end
    end
    gc()
end

Variable definitions are permanent but can be nulled. To free types and the like wrap them in modules. For more info see the first two questions here.

Upvotes: 3

Related Questions