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

**URL:** <https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [February 22, 2024, 3:03am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558 "2024-02-22T03:03:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 22, 2024, 3:03am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/1 "2024-02-22T03:03:15Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/7/4/7468594126d80ccee96d9aee11f2ecb93ac55b85.png)

![image](https://global.discourse-cdn.com/julialang/original/3X/a/5/a5ee135b3faf2daec2aa07700ad3b1b6b8aeae9c.png)

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

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [February 22, 2024, 3:04am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/2 "2024-02-22T03:04:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Post date:** [February 22, 2024, 3:12am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/3 "2024-02-22T03:12:27Z")

</div>

ProgressBars.jl should fit the bill!

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [February 22, 2024, 3:12am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/4 "2024-02-22T03:12:47Z")

</div>

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

```julia
julia> for i in 1:20
           print("\r"*raw"-\|/"[i%4+1]*"="^i*" "^(20-i)*"|")
           sleep(0.2)
       end;
       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.

---

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [February 22, 2024, 3:24am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/5 "2024-02-22T03:24:56Z")

</div>

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. 🤔

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [February 22, 2024, 3:38am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/6 "2024-02-22T03:38:34Z")

</div>

see [Pkg.jl/src/API.jl at 76070d295fc4a1f27f852e05400bbc956962e084 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/blob/76070d295fc4a1f27f852e05400bbc956962e084/src/API.jl#L1389)

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [February 22, 2024, 3:42am UTC](https://discourse.julialang.org/t/how-to-achieve-a-similar-progress-bar-effect-in-my-own-code/110558/7 "2024-02-22T03:42:30Z")

</div>

> [@Oscar\_Smith](#):
>
> I believe it’s just a loop that prints unicode characters

The progress bar part is implemented in [Pkg.jl/src/MiniProgressBars.jl](https://github.com/JuliaLang/Pkg.jl/blob/cc71837381da2569b0d8e9d2c6130a13f3f5b8f4/src/MiniProgressBars.jl#L29), 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.
