https://github.com/lmittmann/style
🌈 Terminal string styling
https://github.com/lmittmann/style
ansi chalk color pypi python string-styling style terminal
Last synced: 11 months ago
JSON representation
🌈 Terminal string styling
- Host: GitHub
- URL: https://github.com/lmittmann/style
- Owner: lmittmann
- License: mit
- Created: 2017-01-19T14:27:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-05-03T14:22:01.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T04:51:20.250Z (12 months ago)
- Topics: ansi, chalk, color, pypi, python, string-styling, style, terminal
- Language: Python
- Homepage: https://pypi.org/project/style
- Size: 21.5 KB
- Stars: 11
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
style
=====
|Build Status| |PyPI version|
**style** is a simple terminal string styling package. Its API is a port of the popular
`chalk `__ package for javascript.
Install
-------
::
$ pip install style
Usage
-----
.. code:: py
import style
print(style.red('Hello', style.bold('world') + '!'))
API
---
style.\ ``style*[.style](*objects, sep=' ')``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chain `styles <#styles>`__ and call the last one as a method with an argument. Order doesn't matter, and later styles
take precedence in case of a conflict, e.g. ``style.red.yellow.green`` is equivalent to ``style.green``. Styles can
be nested.
Multiple arguments will be separated by ``sep``, a space by default.
style.\ ``enabled``
~~~~~~~~~~~~~~~~~~~
Color support is automatically detected, but can also be changed manually.
- set ``style.enabled`` to ``True`` or ``False``
- use the command line parameter ``--color`` or ``--no-color``
Styles
------
+---------------------+-------------------------------------+-------------------------------------------+
| Modifiers | Colors | Background colors |
+=====================+===============+=====================+==================+========================+
| - ``bold`` | - ``black`` | - ``light_black`` | - ``on_black`` | - ``on_light_black`` |
| - ``dim`` | - ``red`` | - ``light_red`` | - ``on_red`` | - ``on_light_red`` |
| - ``italic`` | - ``green`` | - ``light_green`` | - ``on_green`` | - ``on_light_green`` |
| - ``underline`` | - ``yellow`` | - ``light_yellow`` | - ``on_yellow`` | - ``on_light_yellow`` |
| - ``inverse`` | - ``blue`` | - ``light_blue`` | - ``on_blue`` | - ``on_light_blue`` |
| - ``hidden`` | - ``magenta`` | - ``light_magenta`` | - ``on_magenta`` | - ``on_light_magenta`` |
| - ``strikethrough`` | - ``cyan`` | - ``light_cyan`` | - ``on_cyan`` | - ``on_light_cyan`` |
| | - ``white`` | - ``light_white`` | - ``on_white`` | - ``on_light_white`` |
+---------------------+---------------+---------------------+------------------+------------------------+
.. |Build Status| image:: https://travis-ci.com/lmittmann/style.svg?branch=master
:target: https://travis-ci.com/lmittmann/style
.. |PyPI version| image:: https://img.shields.io/pypi/v/style.svg
:target: https://pypi.org/project/style