Last active
September 10, 2025 05:17
-
-
Save singularitti/27033bd6c5b516a9a0c467787d3c26f0 to your computer and use it in GitHub Desktop.
Julia startup config #Julia #startup #config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #=-------------------------------------------------------------------------------------+ | |
| | _____ __ __ _ __ | | |
| | / ___// /_____ ______/ /___ ______ (_) / | | |
| | \__ \/ __/ __ `/ ___/ __/ / / / __ \ / / / | | |
| | ___/ / /_/ /_/ / / / /_/ /_/ / /_/ / / / / | | |
| | /____/\__/\__,_/_/ \__/\__,_/ .___(_)_/ /_/ | | |
| | /_/ /___/ | | |
| +-------------------------------------------------------------------------------------=# | |
| #======================================================================================= | |
| ENV | |
| =======================================================================================# | |
| let | |
| ROOT = abspath(Sys.BINDIR, "..") | |
| ENV["PATH"] = "$(Sys.BINDIR):$(ENV["PATH"])" | |
| ENV["TK_LIBRARY"] = "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts" | |
| ENV["JULIA_PKG_SERVER_REGISTRY_PREFERENCE"] = "eager" | |
| ENV["JULIA_EDITOR"] = "code" | |
| ENV["JULIA_IMAGE_THREADS"] = 12 | |
| ENV["MPLBACKEND"] = "MacOSX" | |
| ENV["PYTHON"] = "" | |
| end | |
| insert!(LOAD_PATH, 2, mktempdir()) # See https://github.com/m3g/JuliaNotes.jl/blob/4528a7a/docs/src/startup.md?plain=1#L28-L34 | |
| #======================================================================================= | |
| REPL | |
| =======================================================================================# | |
| atreplinit() do repl | |
| repl.options.iocontext[:compact] = false # See https://docs.julialang.org/en/v1/stdlib/REPL/#The-Julian-mode | |
| try # See https://docs.julialang.org/en/v1/stdlib/REPL/#Numbered-prompt | |
| @eval import REPL | |
| if !isdefined(repl, :interface) | |
| repl.interface = REPL.setup_interface(repl) | |
| end | |
| REPL.numbered_prompt!(repl) | |
| catch e | |
| @warn "error while setting up numbered prompt" e | |
| end | |
| try # See https://juliasnippets.blogspot.com/2018/11/disabling-auto-indentation-of-code-in.html | |
| @eval using REPL: GlobalOptions, LineEdit | |
| @eval GlobalOptions.auto_indent = false | |
| @eval LineEdit.options(s::LineEdit.PromptState) = GlobalOptions | |
| catch e | |
| @warn "error while disabling auto-indentation of code in Julia REPL" e | |
| end | |
| @async @eval begin | |
| using OhMyREPL: enable_autocomplete_brackets, colorscheme! | |
| colorscheme!("Monokai16") | |
| enable_autocomplete_brackets(false) | |
| end | |
| @async @eval using Pipette | |
| @async @eval using TerminalPager: pager, @help, @out2pr | |
| end | |
| # See https://github.com/wangl-cc/LazyStartup.jl/issues/11#issuecomment-1479302752 | |
| using LazyStartup: lazy_startup_init!, @lazy_startup | |
| lazy_startup_init!() | |
| #======================================================================================= | |
| Project | |
| =======================================================================================# | |
| if isfile("Project.toml") | |
| using Pkg | |
| Pkg.activate(".") | |
| @async @eval using Test | |
| end | |
| #======================================================================================= | |
| Science | |
| =======================================================================================# | |
| @lazy_startup const F64 = Float64 | |
| @lazy_startup const F32 = Float32 | |
| @lazy_startup const Vec = Vector | |
| @lazy_startup const Mat = Matrix | |
| @lazy_startup using Unitful @u_str | |
| @lazy_startup using UnitfulAtomic @u_str | |
| @lazy_startup using LinearAlgebra dot det norm | |
| @lazy_startup using Dates format now | |
| #======================================================================================= | |
| Profiling | |
| =======================================================================================# | |
| @lazy_startup using Chairmarks @b() @be() | |
| @lazy_startup using PrettyChairmarks @bs | |
| @lazy_startup using ChairmarksExtras @btimed | |
| @lazy_startup using Profile @profile | |
| #======================================================================================= | |
| Introspection | |
| =======================================================================================# | |
| @lazy_startup const cl = collect | |
| @lazy_startup const col = collect | |
| @lazy_startup const et = eltype | |
| @lazy_startup const fn = fieldnames | |
| @lazy_startup const len = length | |
| @lazy_startup const mo = methods | |
| @lazy_startup const mw = methodswith | |
| @lazy_startup const prl = println | |
| @lazy_startup const prt = print | |
| @lazy_startup const st = supertypes | |
| @lazy_startup const sth = something | |
| @lazy_startup const to = typeof | |
| @lazy_startup using CheckDoc checkdocs | |
| @lazy_startup using ExproniconLite @expr | |
| @lazy_startup using NicePipes @grep | |
| @lazy_startup using TypeTree tt | |
| @lazy_startup using JET report_package @report_opt() @report_call() | |
| @lazy_startup using About about | |
| @lazy_startup using SoftGlobalScope @softscope | |
| @lazy_startup using Debugger @enter | |
| @lazy_startup using Cthulhu @descend | |
| @lazy_startup macro about(x) | |
| Expr(:call, About.about, x) | |
| end | |
| @lazy_startup function mis(f) | |
| m = Core.MethodInstance[] | |
| visit(f) do x | |
| if isa(x, Core.MethodInstance) | |
| push!(m, x) | |
| false | |
| end | |
| true | |
| end | |
| return m | |
| end | |
| # See https://github.com/JuliaLang/julia/issues/29223#issuecomment-2099200351 | |
| @lazy_startup showall(x) = show(IOContext(stdout, :compact => false, :limit => false), "text/plain", x) | |
| @lazy_startup const swa = showall | |
| @async @eval begin | |
| using CodeTracking: whereis | |
| function mloc(m) | |
| file, line = whereis(m) | |
| return join([file, line], ':') | |
| end | |
| end | |
| @async @eval using MethodAnalysis | |
| @async @eval begin | |
| using Revise | |
| # See https://github.com/timholy/CodeTracking.jl/blob/master/README.md#location-information | |
| Revise.track(Base) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment