Changing the REPL prompt from startup file

I know it’s currently possible to change the REPL prompt. The relevant mystic runes are:

julia> Base.active_repl.interface.modes[1].prompt="v$VERSION> "
"v0.5.0> "

But I’d like to add this to the .juliarc.jl startup file, so that it automatically picks up the correct version. I think there’s something like an atreplinit() function, but I’ve not managed to get it working…

I’m currently switching between v0.4, v0.5, and v0.6, so I think this might be quite useful.

1 Like

It is your lucky day:

Feel free to guinea pig:

Edit: Seems like there are still some troubles putting it in the .juliarc.jl file. Will fix it.


Looks pretty cool! (I love to primp my working environment…) Is it registered?

Nah, I’m overwriting methods in Base left and write and the number of tests are not so good… Don’t think it would hold up to the METADATA scrutiny.

I got it working in .juliarc.jl on 0.5 but 0.6 is still a bit tricky.

The reason why you can’t just do it inside atreplinitis because the .interface field (the different prompts) are not loaded yet at that point.

Yes, I see what you mean.

Currently I’m doing this in the .juliarc.jl file:

@spawn @sync begin
    Base.active_repl.interface.modes[1].prompt="v$VERSION> "

It’s the only way I can currently think of to evaluate the expression after the REPL starts running. There should be an easier way, though…

1 Like

That’s a nice workaround.


I’ve been experimenting with using powershell for shell mode on Windows, and can adapt this using modes[2] to display prompt powershell> .

But not really sure what @sync is doing. I don’t think you need or want this.

So the sneaky thing to do is to put something like this:

if !isdefined(repl,:interface)
    repl.interface = Base.REPL.setup_interface(repl)

in the atreplinit function. Then you create the interface yourself and you can then access the prompts. Found it by looking at

I merged the PR. Should be no problem putting it in .juliarc.jl.

Docs at


It works great! Except that currently OhMyREPL seems to be unusable on 0.6.

Yeah it is too much work to keep up to date with master all the time.

I got it to work just now but the lag is substantial for invoking the REPL, so I ditched it and went back to REPL.default … sorry @kristoffer.carlsson

FWIIW: versioninfo()

Julia Version 0.6.0-dev.2836
Commit 3958491 (2017-02-17 04:31 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: AMD FX™-8320 Eight-Core Processor

Yeah, you need to compile it into the sysimg.jl (as the docs say) for it to be fast. If you only want to change the REPL prompt you don’t need the package, can just use the atreplinit function.

1 Like

OK, I’ll stick “compile the REPL” on my list of things to do … which grows larger hourly.

Great stuff! I’ll switch to OhMyREPL one day, but I wanted to explore the mechanics of this while I was at it.

For what it’s worth, with your and Keno’s help I’ve got as far as this in my juliarc.jl. It’s a bit peculiar: the prompt information is at the right side of the Terminal window. It’s odd, but I’m starting to like it:

# for versions 0.5 and above

function prompt_prefix()
    return ""

function prompt_suffix()
    currentversion = "v$(VERSION.minor) "
    timestamp = Dates.format(now(), "HH:MM:SS")
    workingdirectory = last(splitdir(pwd()))
    return string("$MOVE_COL_80 $timestamp $COLOR_GREEN $currentversion $COLOR_YELLOW $workingdirectory $COLOR_RESET")

function customizeprompts(repl)
    if !isdefined(repl, :interface)
        repl.interface = Base.REPL.setup_interface(repl)
    # prompt prefix
    prefix = repl.interface.modes[1].prompt_prefix
    repl.interface.modes[1].prompt_prefix = function ()
        (prompt_prefix() * (isa(prefix, Function) ? prefix() : prefix))
    # actual prompt string unscathed

    # prompt suffix    
     suffix = repl.interface.modes[1].prompt_suffix
     repl.interface.modes[1].prompt_suffix = function ()
         ((isa(suffix,Function) ? suffix() : suffix) * prompt_suffix())

Other things I’ve tried mess up the line editing a lot more…

1 Like might make it easier to mess around with color and styles.


Awesome. Typing using Crayons is strangely pleasing… :slight_smile:

For what it’s worth, the way I do it in .juliarc.jl without the lag or other tricks is this:

function myrepl(repl)
    repl.interface = REPL.setup_interface(repl)
    repl.interface.modes[1].prompt = "julia-$(VERSION.major).$(VERSION.minor)> "

function myrepl(repl)
    repl.interface = REPL.setup_interface(repl)
    repl.interface.modes[1].prompt = "julia-$(VERSION.major).$(VERSION.minor)> "


Does anyone know the equivalent for v0.7?

1 Like

That works perfectly fine for me on v0.7. Just add a using REPL to avoid the deprecation warnings. (Note that .juliarc.jl have changed to .julia/config/startup.jl, perhaps thats why you don’t see the effect?)