Okay listen up 👂🏻... we all try to fix our lives by building new habits right? 🚴♂️📖🧘 But tracking them? A whole different struggle. 📉
But what if... you had a clean little CLI app — right inside Termux — that keeps track of your goals, shows your progress, and makes habit-building lowkey FUN? 😍
✨ No app installs. No trackers. Just your terminal and your discipline on beast mode 🧠🗓
📚 What You’ll Learn
- ⚙️ Create a local habit tracker with Python
- 💾 Save your data in JSON
- 📆 Mark habits as complete each day
- 📈 Show habit streaks + progress
- 🚀 Make it your DAILY terminal ritual
🔢 Step-by-Step Setup
Step 1: Install Termux Essentials 📦
pkg update && pkg upgrade
pkg install python
pkg install nano
💡 Pro tip: You can also use vim
or micro
instead of nano if you're fancy 😎
Step 2: Create Your Habit Tracker Script 🧑💻
Run this in Termux:
nano habit-tracker.py
Then copy-paste this beauty inside 🧠👇
import json
import os
from datetime import date
FILE = "habits.json"
def load_habits():
if os.path.exists(FILE):
with open(FILE, "r") as f:
return json.load(f)
return {}
def save_habits(habits):
with open(FILE, "w") as f:
json.dump(habits, f, indent=2)
def mark_habit(habits):
today = str(date.today())
print("\nYour Habits:")
for idx, habit in enumerate(habits.keys(), 1):
print(f"{idx}. {habit}")
choice = int(input("\nWhich habit did you complete today? (number): "))
habit = list(habits.keys())[choice - 1]
habits[habit].append(today)
print(f"✅ Marked '{habit}' for {today}!")
def view_progress(habits):
for habit, dates in habits.items():
print(f"\n📌 {habit} — {len(set(dates))} days tracked")
def main():
habits = load_habits()
while True:
print("\n1️⃣ Add Habit\n2️⃣ Mark as Done\n3️⃣ View Progress\n4️⃣ Exit")
choice = input("Enter choice: ")
if choice == "1":
new_habit = input("Enter new habit: ")
habits[new_habit] = []
print(f"🎯 Added new habit: {new_habit}")
elif choice == "2":
mark_habit(habits)
elif choice == "3":
view_progress(habits)
elif choice == "4":
break
else:
print("⚠️ Invalid option")
save_habits(habits)
if __name__ == "__main__":
main()
🔥 Tip: You can always reset by deleting the habits.json
file
Step 3: Run It Like a Ritual 🔁
python habit-tracker.py
Start by adding your daily habits like "Read 5 pages", "Drink 2L water", "Meditate" etc 🧘♂️💧📚
Then mark them daily ✅✅✅ — super satisfying trust me 😌📆
🚀 Make it Cooler with Aliases 😎
Add this to your .bashrc
or .zshrc
👇
alias habits="python ~/habit-tracker.py"
Now just type habits
every day in your Termux to stay on track 📈🔥
✨ Some Spicy Add-On Ideas
- 🎨 Add colors with
termcolor
- 🔔 Push Termux notifications with
termux-notification
- 💾 Auto sync with Git to back up your JSON
- 📊 Show progress with bar charts using
tqdm
orrich
[💬 Lemme know if you want a part 2 with voice-based tracking 👀🎙️]
💬 Wanna Show Off Your Habits?
DM me your screenshots 🧾📸 or tag me on IG 👉 @saadisdope
Also check the 🧠 cool courses and hacks on 👉 course.learntermux.tech
🌱 Final Thoughts
Discipline hits different when YOU coded your own tools 🔥🧑💻
This lil' app can literally keep your goals alive — one checkbox at a time ✅✅✅
Stay productive. Stay creative. Stay Ethical 👾
0 Comments