#!/usr/bin/env python3 # QUOTES: Cross-platform random quote generator. Reads from a plain text file. # Usage: ./quotes.py [path/to/quotes.txt] # Unix/macOS/Linux # python quotes.py [path\to\quotes.txt] # Windows # Tip: Edit QUOTE_FILE in the script to set a default location for quotes.txt # Blue Oak Council License 1.0.0 - https://blueoakcouncil.org/license/1.0.0 # 08 Jul 2025: Initial Release - (c) 640kb.neocities.org # 14 Dec 2025: fixed file path issue when using the tilde. import os import random import sys # Enter the "quotes.txt" full path below (or "quotes path/anyFilename.txt") QUOTE_FILE = '~/bin/quotes.txt' def get_random_quote(file_path): file_path = os.path.expanduser(file_path) try: with open(file_path, 'r') as file: lines = [line.strip() for line in file if line.strip() and not line.strip().startswith('#')] if not lines: return "No quotes available." return random.choice(lines) except FileNotFoundError: return f"Error: Quote file '{file_path}' not found." if __name__ == "__main__": quote_file = sys.argv[1] if len(sys.argv) > 1 else QUOTE_FILE quote = get_random_quote(quote_file) print(f"\n{quote}\n")