How to open a Julia repl in a specific mode

Viewed 181

I want to have a short script that opens a Julia REPL in a specific mode, for instance, the shell> mode or the C++ > (from Cxx.jl) mode. How can this be achieved?

Update: After getting an answer I created a script to start Julia REPL in Cxx.jl C++ mode (and pre-run some C++ code). See it here: https://github.com/cdsousa/cxxrepl.jl.

1 Answers

Whatever this may be good for...

The easiest way (without having dug into the innards of Base.REPL) is to write the appropriate character to STDIN, e.g

write(STDIN.buffer,'?');

If you want to start the REPL and drop to shell mode immediately, call julia as

julia -i -e write(STDIN.buffer,';')
Related