Skip to content

colinfrisch/terminal-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

logo

Terminal Style - simple text styling for your terminal

Package Python 3.10+ PyPI PyPI - Downloads PyPI - License
Meta linting - Ruff code style: black

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

Using terminal-style : 3 tools that will make your life easier

  • sprint acts like print but allows you to style the text :
sprint("Hello, world!", color="red", bold=True)

logo



  • 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),
)

logo



  • 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")

logo



Available Styles

color/bg_color Spinner Text Effect
black dots β ‹ bold
red line | dim
green arrow ← italic
yellow bouncingBar [ ] underline
blue bouncingBall ( ● ) blink
magenta/purple earth 🌍 reverse
cyan moon πŸŒ‘ hidden
white weather β˜€οΈ strikethrough
bright_black/gray/grey hearts πŸ’› strike
bright_red growHorizontal ▏ double_underline
bright_green modern β–°β–±β–±β–±β–±β–±β–± overline
bright_yellow growVertical ▁
bright_blue
bright_magenta
bright_purple
bright_cyan
bright_white
orange
pink
light_pink
deep_pink
lime
gold
navy
maroon
olive
teal
silver
brown
indigo
violet
turquoise
coral
salmon
khaki
crimson
forest_green
sky_blue
lavender
peach
mint

Incoming Features

  • automatic indentation of text
  • pre-built styles for common use cases
  • support for custom styles

Development

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

License

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!

About

Finally print styled text easily in your terminal

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages