Last active
June 4, 2021 12:47
-
-
Save piotrkilczuk/98f9885d051c6d7e2426c09a23923e4b to your computer and use it in GitHub Desktop.
pythonstartup_dynamic_prompt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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