Video The Julia REPL
Last updated: January 12, 2023
Table of contents
If you double-click the Julia executable or if you run the julia
command on the terminal, you will enter the Julia read-eval-print loop or REPL. This is the simplest way to run an interactive Julia session.
This short video is an introduction to the Julia REPL:
REPL modes
The Julia REPL has 4 modes:
julia> Julian mode to run code. Default mode. Go back to it from other modes with Backspacehelp?> Help mode to access documentation. Enter it with ?
shell> Shell mode to run Bash commands. Enter it with ;
(env) pkg> Package manager mode to manage external packages. Enter it with ]
(env is the name of your current project environment. Project environments are similar to Python's virtual environments and allow you, for instance, to have different package versions for different projects. By default, it is the current Julia version. So what you will see is (v1.7) pkg>).
REPL keybindings
In the REPL, you can use standard command line (Emacs) keybindings:
C-c cancel C-d quit C-l clear console C-u kill from the start of line C-k kill until the end of line C-a go to start of line C-e go to end of line C-f move forward one character C-b move backward one character M-f move forward one word M-b move backward one word C-d delete forward one character C-h delete backward one character M-d delete forward one word M-Backspace delete backward one word C-p previous command C-n next command C-r backward search C-s forward search
Running Julia in a Jupyter notebook
While running Julia in a Jupyter notebook, note that the various Julia modes (help, shell, and package) can still be accessed. Since the code cells in Jupyter don't have prompts, you won't see the fancy prompt change that you would see in the REPL.
Nevertheless, running, for instance, ; pwd
will run pwd
in shell mode.