How to print rotating ◓->tick as progress bar in terminal?

Hi all

I’m looking into progress bar options for Julia. Many packages, during installation, show a rotating ◓ becoming a tick when finished. Anyone can help how to print out this dynamic symbol?

Thanks a lot!

Not the rotating symbol but GitHub - timholy/ProgressMeter.jl: Progress meter for long-running computations offers a progress bar.

4 Likes

Looks like it is mixed in with the precompile monitoring logic, but the list of characters is easy to grab:

2 Likes

See also this issue to add spinner animations to ProgressMeter.jl, which links to some sample code: Different ProgressBar styles? · Issue #92 · timholy/ProgressMeter.jl · GitHub

4 Likes

Thank you, it is very helpful.

A PR to support rotating “spinners” in ProgressMeter.jl is here: add spinner option to ProgressUnknown by stevengj · Pull Request #206 · timholy/ProgressMeter.jl · GitHub

3 Likes

With the latest version of ProgressMeter (1.7.1), you can now just pass spinner=true when creating a ProgressUnknown meter. For example:

prog = ProgressUnknown("Working hard:", spinner=true)
while true
    ProgressMeter.next!(prog)
    rand(1:2*10^8) == 1 && break
end
ProgressMeter.finish!(prog)
12 Likes

Another (somewhat silly) way to draw a spinner:

command = "
  t=Threads.@async read(stdin, Char)
  while !istaskdone(t)
    for q=['◒','◐','◓','◑']
      print(q)
      sleep(0.1)
      print('\b')
    end
  end
";
let
  proc_input = Pipe();
  proc = run(pipeline(`julia -e $command`, stdin = proc_input, stdout = stdout, stderr = stderr), wait = false)
  sleep(2)
  write(proc_input,'c') #Signal the spinner process to stop
  while(process_running(proc))
    sleep(0.1)
  end
end


The spinner is drawn by shelling out to an external Julia process, which has its downsides, but it can update completely independently of the main process. I could never get kill() to work here, so the spinner process just runs until it reads something from its stdin.