Skip to main content

Swag up your shell output with escape code magic!

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swag-2.0.5.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

swag-2.0.5-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file swag-2.0.5.tar.gz.

File metadata

  • Download URL: swag-2.0.5.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-121-generic

File hashes

Hashes for swag-2.0.5.tar.gz
Algorithm Hash digest
SHA256 cd5b2aed541107ffa657d5e21e4b50482f0f7489c452726fb07cfa1e80e615d2
MD5 85c8a8250f63a5014ee9448a8ca3ab1a
BLAKE2b-256 608ceef58ffc3ab296ecc8489a8a362ee25a12267786c27350b35a0b302660d9

See more details on using hashes here.

File details

Details for the file swag-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: swag-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-121-generic

File hashes

Hashes for swag-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 efadd2bc0061a6e95e2d74651b36619c97deb6b9b9646a64ad95cb135ed6581a
MD5 906ca7ddc55d7e1f987b2ee509eda2d6
BLAKE2b-256 adc35beed1d0b3c7f3a8f82808256c435171c8dbc778cec56c17e91370751688

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page