DEV Community

Cover image for Alive Progress Bars 🚀
Lawani Elyon John
Lawani Elyon John

Posted on

Alive Progress Bars 🚀

Add Life to Your Terminal with Alive Progress Bar

If you’re tired of plain terminal output, here’s something fun! This demo uses the alive_progress library to add an interactive progress bar that visually updates as tasks progress. It’s perfect for those times when you want to bring some life to your terminal! 🎨

📝 What is Alive Progress Bar?

alive_progress creates an animated progress bar that adapts to task speed, making it great for visualizing longer tasks and improving UX in CLI apps. Plus, it’s open-source and easy to implement!

🛠️ Setting Up

  1. Install alive_progress by running:
   pip install alive-progress
Enter fullscreen mode Exit fullscreen mode
  1. Run the Code

Here’s a simple example:

   from alive_progress import alive_bar
   import time

   for x in 1000, 1500, 700, 0:
       with alive_bar(x) as bar:
           for i in range(1000):
               time.sleep(.005)
               bar()
Enter fullscreen mode Exit fullscreen mode

🎛️ How It Works

The code cycles through different task durations, with each one triggering a unique progress animation in the terminal:

  • x: Sets the task duration.
  • alive_bar(x): Initializes the progress bar.
  • bar(): Updates it each loop cycle.

Try experimenting with these values to see different speeds in action!

📸 Showcase

Here’s a snapshot of it in action:

Image1

Image2

📣 Why Use It?

It makes waiting less boring and adds professionalism to your scripts. Try it out, and let me know what you think! Check out the official alive_progress GitHub page for more features.


Give it a try and enjoy coding with style! 😎

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free