KristofferC / OhMyREPL.jl

Syntax highlighting and other enhancements for the Julia REPL
https://kristofferc.github.io/OhMyREPL.jl/latest/
Other
746 stars 57 forks source link

Custom prompt incompatible with IPython prompt #325

Open mbaz opened 1 year ago

mbaz commented 1 year ago

It seems it is not possible to have both the new IPython prompt in Julia 1.9, and a custom OhMyREPL prompt at the same time.

With this startup.jl, a custom prompt is displayed:

atreplinit() do repl
    if !isdefined(repl, :interface)
        repl.interface = REPL.setup_interface(repl)
    end
    REPL.numbered_prompt!(repl)
    try
        @eval using OhMyREPL
        @eval OhMyREPL.input_prompt!(() -> "("*splitpath(Base.active_project())[end-1]*") julia> ")
    catch e
        @warn "error while importing OhMyREPL" e
    end
end

Writing the if block below the try block results in the IPython prompt. So, it seems configuring one prompt overrides the other.

Interestingly, the Out dictionary is still enabled when the custom prompt is displayed, but it only records the last result:

(v1.9) julia> 1+1
2

(v1.9) julia> Out
Dict{Int64, Any} with 1 entry:
  0 => 2

(v1.9) julia> 2+2
4

(v1.9) julia> Out
Dict{Int64, Any} with 1 entry:
  0 => 4

Maybe a reasonable compromise would be to supress the In prompt when using a custom prompt, but still show a functional Out prompt.