How to achieve a similar progress bar effect in my own code?



How to achieve a similar progress bar effect (and the rotating circle symbol underneath it) in my own code to the project precompilation process?

I believe it’s just a loop that prints unicode characters (and does some slightly fancy stuff to overwrite the original line).

1 Like

ProgressBars.jl should fit the bill!


Most of this can be achieved with simple code like this:

julia> for i in 1:20
           print("\r"*raw"-\|/"[i%4+1]*"="^i*" "^(20-i)*"|")
       println("\r done                 ")

Two main points: The special character \r which returns the cursor to the start of the line and using print instead of println.

For anything fancier (e.g. multiline redraws) you probably would have much more pleasant time using a “terminal user interface” library instead of doing it from scratch. If all you need is a fancy progress bar, probably the already suggested ProgressBars.jl would work for you.


I would love to know what Julia’s original code is for this effect and want to keep it in a same style my own code. :thinking:

see Pkg.jl/src/API.jl at 76070d295fc4a1f27f852e05400bbc956962e084 · JuliaLang/Pkg.jl · GitHub


The progress bar part is implemented in Pkg.jl/src/MiniProgressBars.jl, not sure where the spinning circle list is.
MiniProgressBars is a submodule of Pkg, so you can import from it. I’m not sure how smoothly you can appropriate the functions in there to replicate the precompiling progress bar. The module is also not documented so it’s very probably not public, which is allowed to break in minor revisions.