What's the `In [N]:` prompt? Does it support copy-paste?

What prompt is that? (Does the copy/paste works as with the standard Julia prompt?)

It’s basically like what IJulia does (I think inspired by IPython?), you get numbered promps and return values are stored in an Out dict, e.g. above I can do:

In [6]: Out[3]
5×5 Diagonal{Bool, Vector{Bool}}:
 1  ⋅  ⋅  ⋅  ⋅
 ⋅  1  ⋅  ⋅  ⋅
 ⋅  ⋅  1  ⋅  ⋅
 ⋅  ⋅  ⋅  1  ⋅
 ⋅  ⋅  ⋅  ⋅  1

Don’t know about the copy/pasting, as I’m on Windows and afaik that never worked on the Windows terminals :slight_smile:


EDIT Yes. it does work I just tried.
No. I just tried.

But setting the prompt color fails. I imagine these this will be fixed for 1.10 (well there’s a chance if someone, maybe me opens an issue).

Another problem is that it looks nearly-exactly like the ipython prompt. So if you have terminals running both Julia and ipython it’s hard to tell at a glance what you are looking at. I tried setting the color some other way. I’m sure it’s possible. But clobbering the prompt function in my startup.jl as follows seems to work for distinguishing them. It replaces "In" with "Julia".

using REPL
function REPL.Numbered.set_prompt(repl::REPL.LineEditREPL, n::Ref{Int})
    julia_prompt = repl.interface.modes[1]
    julia_prompt.prompt = function()
        n[] = REPL.Numbered.repl_eval_counter(julia_prompt.hist)+1
        string("Julia [", n[], "]: ")
#        string(repl.prompt_color, "Julia [", n[], "]: ")

Note, I commented out the attempt at coloring the prompt. This is because the prompt length is measured incorrectly somewhere and this is used for positioning the cursor.

EDIT The following is straight forward, see comments below.

Finally, I don’t know how to search discourse for talk about numbered_prompt!. The underscore and bang symbol seem to be stripped. Or numbered_prompt is interpreted as a search for posts with EITHER numbered OR prompt. Very 1996.

1 Like

Have you tried "numbered_prompt!"? This will use match case search.

I think it should work — it does for me. In fact it’s tested:

Yes, I corrected my post. I was trying with OhMyREPL. It works sometimes with OhMyREPL, sometimes not, depending on what you have already entered. I haven’t been able to nail down what sequence of input causes it to begin failing.

This is not a problem, since OhMyREPL comes with the caveat that it will break things in unpredictable ways.

1 Like

Yes, I tried that before writing my post and was sure that it did not work. But, now that I try it, it works perfectly. Ghosts in my machine today.