https://github.com/jakob-bagterp/colorist-for-python
🌈 Lightweight Python package that makes it easy and fast to print colored text in the terminal 🌈
https://github.com/jakob-bagterp/colorist-for-python
ansi-colors color colors python terminal
Last synced: 7 months ago
JSON representation
🌈 Lightweight Python package that makes it easy and fast to print colored text in the terminal 🌈
- Host: GitHub
- URL: https://github.com/jakob-bagterp/colorist-for-python
- Owner: jakob-bagterp
- License: other
- Created: 2022-01-29T07:27:31.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T14:15:52.000Z (over 1 year ago)
- Last Synced: 2024-05-01T16:31:12.664Z (over 1 year ago)
- Topics: ansi-colors, color, colors, python, terminal
- Language: Python
- Homepage: https://jakob-bagterp.github.io/colorist-for-python/
- Size: 2.8 MB
- Stars: 22
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/funding.yml
- License: LICENSE.md
- Support: docs/support-and-contribution.md
Awesome Lists containing this project
README
[](https://github.com/jakob-bagterp/colorist-for-python/releases/latest)
[](https://www.python.org)
[](https://github.com/jakob-bagterp/colorist-for-python/blob/master/LICENSE.md)
[](https://codecov.io/gh/jakob-bagterp/colorist-for-python)
[](https://github.com/jakob-bagterp/colorist-for-python/actions/workflows/github-code-scanning/codeql)
[](https://github.com/jakob-bagterp/colorist-for-python/actions/workflows/test.yml)
[](https://pepy.tech/project/colorist)# 🌈 Colorist for Python 🌈
Lightweight Python package that makes it easy and fast to print colored text in the terminal.Ready to try? See [how to install](https://jakob-bagterp.github.io/colorist-for-python/getting-started/installation/).
## Getting Started
### Print Line of Colored Text
How to print a full line of colored text in the terminal:```python
from colorist import green, yellow, redgreen("This is GREEN!")
yellow("This is YELLOW!")
red("This is RED!")
```How it appears in the terminal:

### Print Mixed Text Colors
How to customize colors inside a paragraph and print it in the terminal:```python
from colorist import Colorprint(f"I want {Color.RED}red{Color.OFF} color inside this paragraph")
print(f"Both {Color.GREEN}green{Color.OFF} and {Color.YELLOW}yellow{Color.OFF} are nice colors")
```How it appears in the terminal:

## Other Styling Options
### Print Bright Colors
Most terminals support bright colors that stand more out:```python
from colorist import BrightColorprint(f"I want {BrightColor.CYAN}cyan{BrightColor.OFF} color inside this paragraph")
```How it appears in the terminal:

Remember to use `Color.OFF` or `BrightColor.OFF` every time you want to revert back to the default terminal text style. Otherwise, the color may spill over and into other terminal messages.
### Print Background Colors
```python
from colorist import bg_green, bg_yellow, bg_redbg_green("This is GREEN background!")
bg_yellow("This is YELLOW background!")
bg_red("This is RED background!")
```How it appears in the terminal:

Background colors can also be mixed inside a paragraph:
```python
from colorist import BgColorprint(f"I want {BgColor.RED}red{BgColor.OFF} background color inside this paragraph")
print(f"Both {BgColor.GREEN}green{BgColor.OFF} and {BgColor.YELLOW}yellow{BgColor.OFF} are nice background colors")
```How it appears in the terminal:

```python
from colorist import BgBrightColorprint(f"I want {BgBrightColor.CYAN}cyan{BgBrightColor.OFF} background color inside this paragraph")
```How it appears in the terminal:

As with text colors, remember to use `BgColor.OFF` or `BgBrightColor.OFF` every time you want to revert back to the default terminal text style. Otherwise, the color may spill over and into other terminal messages.
## Foreground Text
| Color | Full Text Function | Color Code | Example |
| ----- | ------------------ | ---------- | ------- |
|  | `green("text")` | `Color.GREEN` |  |
|  | `yellow("text")` | `Color.YELLOW` |  |
|  | `red("text")` | `Color.RED` |  |
|  | `magenta("text")` | `Color.MAGENTA` |  |
|  | `blue("text")` | `Color.BLUE` |  |
|  | `cyan("text")` | `Color.CYAN` |  |
|  | `white("text")` | `Color.WHITE` |  |
|  | `black("text")` | `Color.BLACK` |  |
| - | - | `Color.DEFAULT` | - |
| - | - | `Color.OFF` | - |
|  | `bright_green("text")` | `BrightColor.GREEN` |  |
|  | `bright_yellow("text")` | `BrightColor.YELLOW` |  |
|  | `bright_red("text")` | `BrightColor.RED` |  |
|  | `bright_magenta("text")` | `BrightColor.MAGENTA` |  |
|  | `bright_blue("text")` | `BrightColor.BLUE` |  |
|  | `bright_cyan("text")` | `BrightColor.CYAN` |  |
|  | `bright_white("text")` | `BrightColor.WHITE` |  |
|  | `bright_black("text")` | `BrightColor.BLACK` |  |
| - | - | `BrightColor.DEFAULT` | - |
| - | - | `BrightColor.OFF` | - |## Background
| Color | Full Text Function | Color Code | Example |
| ----- | ------------------ | ---------- | ------- |
|  | `bg_green("text")` | `BgColor.GREEN` |  |
|  | `bg_yellow("text")` | `BgColor.YELLOW` |  |
|  | `bg_red("text")` | `BgColor.RED` |  |
|  | `bg_magenta("text")` | `BgColor.MAGENTA` |  |
|  | `bg_blue("text")` | `BgColor.BLUE` |  |
|  | `bg_cyan("text")` | `BgColor.CYAN` |  |
|  | `bg_white("text")` | `BgColor.WHITE` |  |
|  | `bg_black("text")` | `BgColor.BLACK` |  |
| - | - | `BgColor.DEFAULT` | - |
| - | - | `BgColor.OFF` | - |
|  | `bg_bright_green("text")` | `BgBrightColor.GREEN` |  |
|  | `bg_bright_yellow("text")` | `BgBrightColor.YELLOW` |  |
|  | `bg_bright_red("text")` | `BgBrightColor.RED` |  |
|  | `bg_bright_magenta("text")` | `BgBrightColor.MAGENTA` |  |
|  | `bg_bright_blue("text")` | `BgBrightColor.BLUE` |  |
|  | `bg_bright_cyan("text")` | `BgBrightColor.CYAN` |  |
|  | `bg_bright_white("text")` | `BgBrightColor.WHITE` |  |
|  | `bg_bright_black("text")` | `BgBrightColor.BLACK` |  |
| - | - | `BgBrightColor.DEFAULT` | - |
| - | - | `BgBrightColor.OFF` | - |## Become a Sponsor 🏅
If you find this project helpful, please consider supporting its development. Your donations will help keep it alive and growing. Every contribution, no matter the size, makes a difference.[Donate on GitHub Sponsors](https://github.com/sponsors/jakob-bagterp)
Thank you for your support! 🙌
## Contribute
If you have suggestions or changes to the module, feel free to add to the code and create a [pull request](https://github.com/jakob-bagterp/colorist-for-python/pulls).## Report Bugs
Report bugs and issues [here](https://github.com/jakob-bagterp/colorist-for-python/issues).