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

**URL:** https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750
**Category:** General Usage
**Created:** [May 12, 2023, 3:35pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750 "2023-05-12T15:35:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [May 12, 2023, 3:35pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/1 "2023-05-12T15:35:18Z")

</div>

> [@What is the Julian equivalent of Python's \`np.eye(5, 5, 1)\`](https://discourse.julialang.org/t/what-is-the-julian-equivalent-of-pythons-np-eye-5-5-1/98746/2):
>
> `In [1]: using LinearAlgebra`

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

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [May 12, 2023, 3:44pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/2 "2023-05-12T15:44:19Z")

</div>

> **[Julia 1.9 Highlights](https://julialang.org/blog/2023/04/julia-1.9-highlights/#numbered_prompt)**
>
> Highlights of the Julia 1.9 release.

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:

```julia
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 🙂

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [May 12, 2023, 6:32pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/3 "2023-05-12T18:32:33Z")

</div>

> [@lmiq](#):
>
> Does the copy/paste works as with the standard Julia prompt

_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"`.

```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[], "]: ")
    end
    nothing
end

```

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.~~

---

<div class="post-metadata">

### Author: ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)
#### Post date: [May 12, 2023, 6:38pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/4 "2023-05-12T18:38:39Z")

</div>

> [@jlapeyre](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [May 12, 2023, 6:39pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/5 "2023-05-12T18:39:56Z")

</div>

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

> <https://github.com/JuliaLang/julia/blob/c6fc12c9eee6aa4fb1f584840e5a0f988009d82f/stdlib/REPL/test/repl.jl#L751-L753>

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [May 12, 2023, 6:54pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/6 "2023-05-12T18:54:44Z")

</div>

> [@mbauman](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [May 12, 2023, 6:56pm UTC](https://discourse.julialang.org/t/whats-the-in-n-prompt-does-it-support-copy-paste/98750/7 "2023-05-12T18:56:41Z")

</div>

> [@RoyiAvital](#):
>
> Have you tried `"numbered_prompt!"`? This will use match case search.

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.
