Remove blank lines in REPL

Does anybody know a way to get rid of the blank line in the REPL which appears everytime before an input prompt (except for example when using print(sth))?

I like to use julia as a quick calculator-tool from the terminal for a few operations. But I don’t like wasted space, because then I can see less.

[~]$ julia -q
julia> 3+3
6

julia> 
[~]$ 

In comparison in python it would look like this:

[~]$ python3 -q
>>> 3+3
6
>>> 
[~]$
1 Like

I came across the solution by accident. The culprit here is REPLDisplay.

There are two methods to get rid of it in favor of a simpler TextDisplay:

Method 1: Pop the REPLDisplay off

Base.Multimedia.popdisplay();

Method 2: Add a new TextDisplay

Base.Multimedia.pushdisplay(TextDisplay(stdout));

After using one the two methods above, the output will look like this:

julia> 5+5
10
julia> 3+3
6
julia> 

Unfortunately, I have not yet figured out how to incorporate that into the startup. It seems REPLDisplay is added after the startup script is executed.

3 Likes

If you put this in ~/.julia/config/startup.jl, then the extra blank line goes away.

import REPL: REPLDisplay, display, outstream, answer_color
function display(d::REPLDisplay, mime::MIME"text/plain", x)
    io = outstream(d.repl)
    get(io, :color, false) && write(io, answer_color(d.repl))
    if isdefined(d.repl, :options) && isdefined(d.repl.options, :iocontext)
        # this can override the :limit property set initially
        io = foldl(IOContext, d.repl.options.iocontext,
                   init=IOContext(io, :limit => true, :module => Main))
    end
    show(io, mime, x)
    nothing
end

I just removed the println(io) at julia/REPL.jl at 9790a8db1cb65cb8d1081cd14706939f49e9a771 · JuliaLang/julia · GitHub

1 Like