Video The Julia REPL
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 default way to run an interactive Julia session.
In this course, we will use Jupyter: another way to run an interactive Julia session by running the Julia kernel inside an interactive notebook. So you won't get to play directly in the REPL. Consequently, the keybindings will be those of Jupyter, not those of the REPL given below. It is important however to be familiar with the concept of the Julia REPL as you will encounter it soon enough if you use Julia.
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.5) 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.