Awesome Open Source
Awesome Open Source

.. image:: :target: :align: center :alt: sty_logo

.. image:: :target: :align: center :alt: sty_demo :width: 600px


Simple, flexible and extensible string styling for your terminal. Supports 3/4bit, 8bit and 24bit (truecolor, rgb) colors. Should work on most Unix platfroms with most terminals. Works with recent Windows terminals. Window legacy terminal (cmd) needs a shim <>__ to work.

Sty comes with default color palettes and renderers, but you can easily replace/customize them, without touching the markup.

Sty's goal is to provide Python with a little string styling markup, which is decoupled from color palettes and terminal implementations.

Sty has no dependencies.

If you run into compatibility problems with sty, please file an issue <>__!

Code Example

.. code:: python

from sty import fg, bg, ef, rs

foo = + 'This is red text!' +
bar = + 'This has a blue background!' +
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' +
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' +

# Add custom colors:

from sty import Style, RgbFg = Style(RgbFg(255, 150, 50))

buf = + 'Yay, Im orange.' +

print(foo, bar, baz, qux, qui, buf, sep='\n')

The code above will print like this in the terminal:

.. image:: :target: :align: center :alt: example :width: 600px




Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (44,566
python3 (1,205
terminal (596
command-line (447
color (164
string (69
terminal-based (44
styling (22

Find Open Source By Browsing 7,000 Topics Across 59 Categories