Skip to main content

Swag

Color your shell output with escape code magic.

Demo

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
  print

CLI Usage

Print to the cli

You can print colored from the shell as follows:

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:

swag install --dest <path/to/folder> # default is ~/.colors

This will install all the escape codes to the ~/.colors or <path/to/folder> 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).

swag list

Use from code

Print to the console

from swag import red, green, reset, INTENSE

red("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

from swag import colors
print(f"{colors.red}This will be red{colors.reset}")

License

This project is licensed under the GPL-3 license.

Metadata

Release files for swag 2.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swag 2.0.5
File Size Uploaded
swag-2.0.5.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swag 2.0.5
File Interpreter ABI Platform
swag-2.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 45.8 kB

Release files / swag-2.0.5.tar.gz

Download URL swag-2.0.5.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cd5b2aed541107ffa657d5e21e4b50482f0f7489c452726fb07cfa1e80e615d2
BLAKE2b-256 checksum
How to use checksums
608ceef58ffc3ab296ecc8489a8a362ee25a12267786c27350b35a0b302660d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-121-generic

Release files / swag-2.0.5-py3-none-any.whl

Download URL swag-2.0.5-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efadd2bc0061a6e95e2d74651b36619c97deb6b9b9646a64ad95cb135ed6581a
BLAKE2b-256 checksum
How to use checksums
adc35beed1d0b3c7f3a8f82808256c435171c8dbc778cec56c17e91370751688
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-121-generic

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

1 release file

1.5.0

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page