Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/4thel00z/swag
Color your shell output with escape code magic.
https://github.com/4thel00z/swag
echo print python shell theming
Last synced: 3 months ago
JSON representation
Color your shell output with escape code magic.
- Host: GitHub
- URL: https://github.com/4thel00z/swag
- Owner: 4thel00z
- License: gpl-3.0
- Created: 2017-02-18T15:12:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-22T10:37:32.000Z (5 months ago)
- Last Synced: 2024-11-24T16:52:10.205Z (3 months ago)
- Topics: echo, print, python, shell, theming
- Language: Python
- Size: 94.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Swag
Color your shell output with escape code magic.
[![Demo](https://asciinema.org/a/fciEE57CeLkKBQl5uoU51rgPR.svg)](https://asciinema.org/a/fciEE57CeLkKBQl5uoU51rgPR)
## Installation
`pip install swag`
## Usage
```
Usage: swag [OPTIONS] COMMAND [ARGS]...Options:
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.--help Show this message and exit.
Commands:
install
list
```## CLI Usage
### Print to the cli
You can print colored from the shell as follows:
```shell
swag print --color yellow --modifier intense_bold "This text will be intense_bold and yellow :-)"
```The possible modifiers are:
* underline
* background
* bold
* intense
* intense_bold
* intense_background### Installation to a folder
From the commandline do:
```shell
swag install --dest # default is ~/.colors
```This will install all the escape codes to the ~/.colors or folder.
Now you can use the colors directly from the console via:
`echo $(cat ~/.colors/blue) This will be blue`
### List all colors
Prints a list of colors (color coded).
```shell
swag list
```## Use from code
### Print to the console
```python
from swag import red, green, reset, INTENSEred("This will be red")
green("Blah", modifier=INTENSE) # Prints an intense green
# Prints an intense green, to the end of the output, means if you use print after it will be green too:
green("This is green until the end", modifier=INTENSE, continuous=True)
print("This will still be green")
reset() # From now on the default cli color will be used
```### Use the colors in a string
```python
from swag import colors
print(f"{colors.red}This will be red{colors.reset}")
```## License
This project is licensed under the GPL-3 license.