Skip to content

Template for startup.jl file

Martin Otter edited this page Feb 22, 2019 · 1 revision

Store the template file below at C:\Users\<user-name>\.julia\config\startup.jl and adapt the <path> variables. Whenever Julia is started, this startup file is executed:

println("... execution of ", @__FILE__)

# Change prompt colors, since default ones are hard to see on white background
function customize_colors(repl)
   # Customize colors:
   #   https://docs.julialang.org/en/latest/stdlib/REPL/
   #
   # Available colors:
   #   ?Base.text_colors
   #      :normal, :default, :bold, :black, :blink, :blue, :cyan, :green, :hidden, 
   #      :light_black, :light_blue, :light_cyan, :light_green, :light_magenta,
   #      :light_red, :light_yellow, :magenta, :nothing, :red, :reverse, :underline,
   #      :white, or :yellow as well as the integers 0 to 255 inclusive.
   #
   #
   repl.prompt_color = Base.text_colors[:blue]
   repl.help_color   = Base.text_colors[:magenta]
   repl.shell_color  = Base.text_colors[:magenta]
   repl.input_color  = Base.text_colors[:magenta]
   repl.answer_color = Base.text_colors[:magenta] 
end
Base.atreplinit(customize_colors)
ENV["JULIA_WARN_COLOR"] = :light_red
ENV["JULIA_INFO_COLOR"] = :magenta


# Support revise() in order that code changes are automatically compiled
# (https://timholy.github.io/Revise.jl/stable/config.html)
try
    @eval using Revise
    # Turn on Revise's automatic-evaluation behavior
    Revise.async_steal_repl_backend()
    println("... Revise started")
catch err
    @warn "... Could not load Revise."
end


# Package directory is defined with environment variable:
#    JULIA_DEPOT_PATH
#
println("... Julia package directories: ", DEPOT_PATH)


# Define string macro:  R"string"  which does not interpret special characters like \ in string
macro R_str(s)
  s
end

# When using the Anaconda3 distribution of Python (useful for PyPlot)
#
# ENV["PYTHON"] = R"<path>\Anaconda3\python.exe"
# println("...    ENV[\"PYTHON\"] = \"", ENV["PYTHON"], "\"")

# When using Jupyter notebooks
# 
# ENV["JUPYTER"] = R"<path>\Anaconda3\Scripts\jupyter.exe"
# println("...    ENV[\"JUPYTER\"] = \"", ENV["JUPYTER"], "\"")


# When using DLR-Visualization as used by Modia3D (https://github.com/ModiaSim/Modia3D.jl) 
# Download of free community edition: https://visualization.ltx.de/
#
# ENV["DLR_VISUALIZATION"] = R"<path>\Visualization\Extras\SimVis"
# println("...    ENV[\"DLR_VISUALIZATION\"] = \"", ENV["DLR_VISUALIZATION"], "\"")


# Change working directory for Julia
cd(R"<path>\.julia\dev")
println("... Starting Julia in " * pwd())
Clone this wiki locally