How to get a handle to the Terminal

I just discovered, by unrelatedly digging into the internals of RemoteREPL.jl, that there is a variable Base.active_repl, which almost is what I want. Specifically, Base.active_repl is a subtype of REPL.AbstractREPL, while I need a subtype of REPL.Terminals.AbstractTerminal. Fortunately, Base.activeREPL has a field t, which fits the bill:

julia> Base.active_repl.t isa REPL.Terminals.AbstractTerminal
true

So to clear the terminal, one can use

REPL.Terminals.clear(Base.active_repl.t);

, where the semi-colon supresses the 7 returned from write.

2 Likes