After building a static CLI dashboard in Python (which already looked π₯), I thought: βWhat if it updated in real-time?β So I did exactly that β and turned my terminal into a live control center.
This dashboard now refreshes every second, showing CPU/RAM usage, current tasks, and system time β all beautifully animated using the rich.live.Live feature.
π§° Libraries Used:
rich
: For layout, live updates, styling, and terminal beauty.
pyfiglet
: For that dramatic ASCII header.
psutil
: To get CPU and RAM usage.
Pythonβs datetime
and time
modules.
π Features
π» Live System Monitoring
CPU and RAM usage update every second using psutil.
π Task Overview
A clean panel shows the status of key operations: Complete β
, Running βοΈ, Pending β³.
π Live Clock
Display the current date and time
in the footer β always accurate.
π¨ Beautiful Layout
Split into header, body (left + right), and footer β all styled withrich
panels.
π Instant Updates
Thanks to rich.live.Live
, the whole layout refreshes seamlessly.
The code:
import pyfiglet
from rich.console import Console, Group
from rich.live import Live
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from rich.layout import Layout
from datetime import datetime
import psutil
import time
console = Console()
def make_header():
banner = pyfiglet.figlet_format("CLI Dashboard", font="slant")
return Panel(Text(banner, justify="center"), style="bold cyan")
def make_system_stats():
cpu = psutil.cpu_percent()
mem = psutil.virtual_memory().percent
return Panel(f"[bold yellow]CPU:[/bold yellow] {cpu}% [bold yellow]RAM:[/bold yellow] {mem}%", title="π Usage")
def make_task_table():
table = Table.grid(expand=True)
table.add_column(justify="left", style="cyan")
table.add_column(justify="right", style="green")
table.add_row("Data Sync", "β
Complete")
table.add_row("Model Training", "βοΈ Running")
table.add_row("Report Generation", "β³ Pending")
return Panel(table, title="π Tasks")
def make_time_panel():
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return Panel(f"[bold magenta]Current Time:[/bold magenta] {now}", border_style="magenta")
def make_layout():
layout = Layout()
layout.split(
Layout(name="header", size=3),
Layout(name="body", ratio=2),
Layout(name="footer", size=3),
)
layout["body"].split_row(
Layout(name="left"),
Layout(name="right")
)
return layout
with Live(console=console, refresh_per_second=1) as live:
layout = make_layout()
while True:
layout["header"].update(make_header())
layout["left"].update(make_system_stats())
layout["right"].update(make_task_table())
layout["footer"].update(make_time_panel())
live.update(layout)
time.sleep(1)
The output:
Output does contains sensitive info dev's . Sorry about that!!
π§ͺ How to Run
Install the required libraries:
pip install rich pyfiglet psutil
Run the script:
python live_dashboard.py
Watch the magic happen β¨
π§ Why I Made This
Because static dashboards are cool. But dynamic ones? Way cooler.
Also:
Practiced real-time rendering in the terminal.
Learned how to refresh rich.layout without screen flicker.
Built something useful and fun for future CLI tools.
π¬ Feedback & Ideas?
Let me know if you'd like to see:
π§ Configurable task input from a JSON or DB.
π Graphing CPU/memory history.
π³ Docker stats or Git hooks integration.
Thanks for reading! If you liked this post, leave a β€οΈ or comment with your ideas. Let's build more terminal magic together! β¨
Top comments (0)