Skip to content

Instantly share code, notes, and snippets.

@piotrkilczuk
Last active June 4, 2021 12:47
Show Gist options
  • Save piotrkilczuk/98f9885d051c6d7e2426c09a23923e4b to your computer and use it in GitHub Desktop.
Save piotrkilczuk/98f9885d051c6d7e2426c09a23923e4b to your computer and use it in GitHub Desktop.
pythonstartup_dynamic_prompt.py
import sys
from datetime import datetime
from os import getcwd
from pathlib import Path
from colorama import Fore
class Ps1:
count: int
def __init__(self):
self.count = 0
def __str__(self):
self.count += 1
command_number = self.count
current_directory = getcwd()
time_as_str = datetime.now().strftime("%H:%M:%S")
return (
f"[{Fore.LIGHTGREEN_EX}#{command_number}{Fore.RESET} "
f"{Fore.LIGHTCYAN_EX}{current_directory}{Fore.RESET} "
f"{Fore.LIGHTBLUE_EX}{time_as_str}{Fore.RESET}] "
)
sys.ps1 = Ps1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment