Change julia promt to include evalutation numbers

When debugging or running julia code in REPL, I usually see error messages showing ... at ./REPL[161]:12 [inlined]... The number 161 means a 161-th grade in REPL, I think. So my question is: can we show this number in the julia tooltip, i.e. julia [161]> instead of julia> ?

+5
source share
1 answer

One of the benefits of Julia is its ultra-flexibility. This is very easy in Julia 0.7 (nightly version).

 julia> repl = Base.active_repl.interface.modes[1] "Prompt(\"julia> \",...)" julia> repl.prompt = () -> "julia[$(length(repl.hist.history) - repl.hist.start_idx + 1)] >" #1 (generic function with 1 method) julia[3] > julia[3] >2 2 julia[4] >f = () -> error("e") #3 (generic function with 1 method) julia[5] >f() ERROR: e Stacktrace: [1] error at .\error.jl:33 [inlined] [2] (::getfield(, Symbol("##3#4")))() at .\REPL[4]:1 [3] top-level scope 

You just need to put the first 2 lines on your ~/.juliarc and enjoy ~

Since there are several changes in REPL after julia 0.7, these codes do not work in older versions.

EDIT: Well, it actually takes a little more effort for it to work in .juliarc.jl . Try this code:

 atreplinit() do repl repl.interface = Base.REPL.setup_interface(repl) repl = Base.active_repl.interface.modes[1] repl.prompt = () -> "julia[$(length(repl.hist.history) - repl.hist.start_idx + 1)] >" end 
+7
source

Source: https://habr.com/ru/post/1274435/


All Articles