Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a Julia repl in a specific mode

Tags:

julia

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.

like image 214
Cristóvão D. Sousa Avatar asked Sep 26 '17 13:09

Cristóvão D. Sousa


People also ask

How do you open the REPL in Julia?

I use ctrl + alt + r to start my REPL.

How do I clear the screen in Julia REPL?

To clear or interrupt a current command, press Ctrl + C. To clear the screen, press Ctrl + L (variables are kept in memory)


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,';')
like image 130
skleinbo Avatar answered Oct 24 '22 02:10

skleinbo