ShareAdd.jl can be combined nicely with BasicAutoloads.jl by @Lilith .
Here is my current startup.jl
:
if VERSION >= v"1.11" && isinteractive()
using ShareAdd
import BasicAutoloads
BasicAutoloads.register_autoloads([
["plot", "scatter"] => :(isdefined(Main, :plot) || @usingany Plots),
["DataFrame", "combine", "transform!", "transform", "select!", "select", "groupby"]
=> :(@usingany DataFrames),
["CSV"] => :(@usingany CSV, StringEncodings, DataFrames),
["Dates", "Date","DateTime"] => :(@usingany Dates),
["mean", "std", "median"] => :(isdefined(Main, :mean) || @usingany Statistics),
["@u_str"] => :(@usingany Unitful),
["@benchmark"] => :(@usingany BenchmarkTools),
])
println("ShareAdd & BasicAutoloads are loaded")
end
Now, should I e.g. type mean([1,2,3])
or 1.55u"V"
in the REPL, Statistics.jl or resp. Unitful.jl would be first silently loaded.
The “main” shared environment, i.e. the folder “~/.julia/environments/v1.11/” contains now only Revise
, ShareAdd
, and BasicAutoloads
. Most “shared” packages are each individually in the eponymous env, like Plots
package is in @Plots
shared env.