Package | |
Meta |
Styling text in a terminal is a pain and weirdly, there are no libraries that are both simple to use and multi-task for this. So I made a very simple lightweight Python library for styling terminal text with colors, backgrounds, and text effects. No complex features, no hassle.
install using pip: pip install -U terminal-style
sprint
acts likeprint
but allows you to style the text :
sprint("Hello, world!", color="red", bold=True)
style
is a function that returns a styled string formatted terminal use. Can be used in regular print statements :
print(
style("Hello", color="red", bold=True),
style("old", color="blue", italic=True),
style("friend", color="green", underline=True),
style("!", color="yellow", bold=True),
)
spinner
is a function that will show a spinner in the terminal : the spinner will stop automatically when a next line is printed in the terminal. It runs in parallel, so don't worry about blocking the main thread.
spinner("Processing...", color="cyan", bold=True, type="dots")
- automatic indentation of text
- pre-built styles for common use cases
- support for custom styles
Contributions are welcome! Please feel free to submit a Pull Request.
git clone https://github.com/colinfrisch/terminal-style
cd terminal-style
pip install -e .
Install development dependencies:
pip install -e ".[dev]"
Run tests:
pytest
# or
python run_tests.py
This project is licensed under the MIT License - see the LICENSE file for details.
Author : Colin Frisch - linkedin.com/colinfrisch
Make your terminal output beautiful and readable with terminal-style!