Julia Notes Day5 -- REPL help/pkg/search mode and Depot


7 min read

Install Julia

All official Julia binaries produce portable installations. Once installed, the directory in which Julia was installed can be moved to a different location on the same computer, or even to a different computer.

wget https://julialang-s3.julialang.org/bin/linux/x64/1.10/julia-1.10.2-linux-x86_64.tar.gz
tar zxvf julia-1.10.2-linux-x86_64.tar.gz

The generic Linux and FreeBSD binaries do not require any special installation steps, but you will need to ensure that your system can find the julia executable. The directory where Julia is installed is referred to as <Julia directory>.

To run Julia, you can do any of the following:

  • Invoke the julia executable by using its full path: <Julia directory>/bin/julia

  • Create a symbolic link to julia inside a folder which is on your system PATH

  • Add Julia's bin folder (with full path) to your system PATH environment variable

To add Julia's bin folder (with full path) to PATH environment variable, you can edit the ~/.bashrc (or ~/.bash_profile) file. Open the file in your favourite editor and add a new line as follows:

export PATH="$PATH:/workspace/empty/julia-1.10.2/bin"


The easiest way to learn and experiment with Julia is by starting an interactive session (also known as a read-eval-print loop or "REPL") by double-clicking the Julia executable or running julia from the command line:

$ julia

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.2 (2024-03-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> 1 + 2

julia> ans

julian mode

The REPL has five main modes of operation. The first and most common is the Julian prompt. It is the default mode of operation; each new line initially starts with julia>. It is here that you can enter Julia expressions. Hitting return or enter after a complete expression has been entered will evaluate the entry and show the result of the last expression.

help mode

You can use the REPL as a learning resource by switching into the help mode. Switch to help mode by pressing ? at an empty julia> prompt, before typing anything else. Typing a keyword in help mode will fetch the documentation for it, along with examples.

julia> using UnicodePlots

help?> lineplot
search: lineplot lineplot!

  lineplot(; kw...)
  lineplot(y; kw...)
  lineplot(x, y; kw...)
  lineplot!(p, args...; kw...)


  Draws a path through the given points on a new canvas.

  The first (optional) vector x should contain the horizontal positions for all the points along the path. The second
  vector y should then contain the corresponding vertical positions respectively. This means that the two vectors must be
  of the same length and ordering.


  lineplot([x], y; head_tail = nothing, ..., name = "")
  lineplot([start], [stop], fun; kw...)


    •  fun : a unary function f: R -> R that should be evaluated, and drawn as a path from start to stop (numbers in
       the domain).

    •  head_tail : color the line head and/or tail with the complement of the chosen color (:head, :tail, :both).

    •  head_tail_frac : fraction of the arrow head or tail (e.g. provide 0.1 for 10%).

    •  x : horizontal position for each point (can be a real number or of type TimeType), if omitted, the axes of y
       will be used as x.

    •  format : specify the ticks date format (TimeType only).

    •  color::Symbol = :auto : Vector of colors, or scalar - choose from (:green, :blue, :red, :yellow, :cyan,
       :magenta, :white, :normal, :auto), use an integer in [0-255], or provide 3 integers as RGB components.

    •  y : vertical position for each point.

    •  title::String = "" : text displayed on top of the plot.

    •  name::String = "" : current drawing annotation displayed on the right.

    •  xlabel::String = "" : text displayed on the x axis of the plot.

    •  ylabel::String = "" : text displayed on the y axis of the plot.

    •  xscale::Symbol = :identity : x-axis scale (:identity, :ln, :log2, :log10), or scale function e.g. x ->

    •  yscale::Symbol = :identity : y-axis scale.

    •  labels::Bool = true : show plot labels.

    •  border::Symbol = :solid : plot bounding box style (:corners, :solid, :bold, :dashed, :dotted, :ascii, :none).

    •  margin::Int = 3 : number of empty characters to the left of the whole plot.

    •  padding::Int = 1 : left and right space between the labels and the canvas.

    •  height::Int = 15 : number of canvas rows, or :auto.

    •  width::Int = 40 : number of characters per canvas row, or :auto.

    •  xlim::Tuple = (0, 0) : plotting range for the x axis ((0, 0) stands for automatic).

    •  ylim::Tuple = (0, 0) : plotting range for the y axis.

    •  xflip::Bool = false : set true to flip the x axis.

    •  yflip::Bool = false : set true to flip the y axis.

    •  canvas::UnionAll = UnicodePlots.BrailleCanvas : type of canvas used for drawing.

    •  grid::Bool = true : draws grid-lines at the origin.

    •  compact::Bool = false : compact plot labels.

    •  unicode_exponent::Bool = true : use Unicode symbols for exponents: e.g. 10²⸱¹ instead of 10^2.1.

    •  blend::Bool = true : blend colors on the underlying canvas.


    •  Christof Stocker (github.com/Evizero)

    •  Milktrader (github.com/milktrader)


  julia> lineplot([1, 2, 7], [9, -6, 8]; title = "My Lineplot")
         ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀My Lineplot⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 
      10 │⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀│ 
         │⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠│ 
         │⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀│ 
         │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀│ 
     -10 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀│ 

  See also

  Plot, scatterplot, stairs, BrailleCanvas, BlockCanvas, AsciiCanvas, DotCanvas

pkg mode

The Package manager mode accepts specialized commands for loading and updating packages. It is entered by pressing the ] key at the Julian REPL prompt and exited by pressing CTRL-C or pressing the backspace key at the beginning of the line. The prompt for this mode is pkg>. It supports its own help-mode, which is entered by pressing ? at the beginning of the line of the pkg> prompt. The Package manager mode is documented in the Pkg manual, available at https://julialang.github.io/Pkg.jl/v1/.

shell mode

Just as help mode is useful for quick access to documentation, another common task is to use the system shell to execute system commands. Just as ? entered help mode when at the beginning of the line, a semicolon (;) will enter the shell mode. And it can be exited by pressing backspace at the beginning of the line.

search mode

In all of the above modes, the executed lines get saved to a history file, which can be searched. To initiate an incremental search through the previous history, type ^R – the control key together with the r key. The prompt will change to (reverse-i-search)`':, and as you type the search query will appear in the quotes. The most recent result that matches the query will dynamically update to the right of the colon as more is typed. To find an older result using the same query, simply type ^R again.

Just as ^R is a reverse search, ^S is a forward search, with the prompt (i-search)`':. The two may be used in conjunction with each other to move through the previous or next matching results, respectively.

Depot Directory

The JULIA_DEPOT_PATH environment variable is used to populate the global Julia DEPOT_PATH variable, which controls where the package manager, as well as Julia's code loading mechanisms, look for package registries, installed packages, named environments, repo clones, cached compiled package images, configuration files, and the default location of the REPL's history file.

Here is an overview of some of the subdirectories that may exist in a depot:

  • compiled: Contains precompiled *.ji files for packages. Maintained by Julia.

  • environments: Default package environments. For instance the global environment for a specific julia version. Maintained by Pkg.jl.

  • logs: Contains logs of Pkg and REPL operations. Maintained by Pkg.jl and Julia.

  • packages: Contains packages, some of which were explicitly installed and some which are implicit dependencies. Maintained by Pkg.jl.

  • registries: Contains package registries. By default only General. Maintained by Pkg.jl.

  • scratchspaces: Contains content that a package itself installs via the Scratch.jl package. Pkg.gc() will delete content that is known to be unused.

export JULIA_DEPOT_PATH="/workspace/empty/depot"