Skip to content

Commit

Permalink
change startup.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed Oct 24, 2023
1 parent ac55e0f commit 11875db
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions docs/src/startup.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# REPL tips at startup.jl

This is my current (as of September 2023) `.julia/config/startup.jl` file:
This is my current (as of November 2023) `.julia/config/startup.jl` file:

```julia
using Revise, BenchmarkTools
using Revise
using BenchmarkTools
import OhMyREPL
OhMyREPL.colorscheme!("TomorrowNightBright")
import Pkg
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
insert!(LOAD_PATH, 2, mktempdir())
OhMyREPL.colorscheme!("TomorrowNightBright")
if occursin(splitpath(Base.active_project())[end-1],"v"*string(VERSION))
Pkg.activate(temp=true)
end
```

- `Revise` and `BenchmarkTools` are important development tools.
- `OhMyREPL` is responsible for syntax highlighting in the REPL.
- `OhMyREPL` is responsible for syntax highlighting in the REPL, and that is my preferred color scheme.

Install first these packages with:

Expand All @@ -25,15 +28,32 @@ the latest version of every package all the time when installing a package in
a new environment. This is nice to avoid many unnecessary downloading and
recompilation runs.

With `insert!(LOAD_PATH, 2, mktempdir())`, a temporary environment is added
The code
```julia
if occursin(splitpath(Base.active_project())[end-1],"v"*string(VERSION))
Pkg.activate(temp=true)
end
```
will check if the active environment is the main one ("v1.10", or similar) and,
in this case, activate a temporary environment instead.
With that adding new packages does not bloat the Main environment.
This is very convenient for testing new
packages. Now (as of Julia 1.9) that precompiled cache files are saved, installing
packages that are already locally available is quick, and thus having a default
temporary environment is quite convenient.

A few time ago I used, instead of `Pkg.activate(temp=true)`,
```
insert!(LOAD_PATH, 2, mktempdir())
```
with which a temporary environment is added
to the list of default environments. This is useful because, when installing
a package automatically after a `using Package` command, one is prompted (by chossing the `o`)
in which environment the package is to be installed. Choosing the tempororary
one (which will be selected by default) will avoid clutering the global environment.
In combination with the above update-registry option, this avoids may recompilation
runs.
runs. But currently I prefer just always starting in a temporary environment.

The last line is my preferred color scheme.



0 comments on commit 11875db

Please sign in to comment.