Skip to content

ASCII art for your terminal! A rework of DistroTube(Derek Taylor)'s color scripts

License

Notifications You must be signed in to change notification settings

stautonico/python-color-scripts

Repository files navigation

Python Color Scripts

ASCII art for your terminal! A rework of DistroTube(Derek Taylor)'s color scripts.

Screenshot of some of the artworks

Derek Taylor (DistroTube) has this script called colorscript which shows a random ASCII art when called. Most people use it when their terminal opens. This is a modified/custom version of that idea.

Dependencies

  • python3 (theoretically, this should work with python2, but I'm not actively testing that)
  • pip
  • requests (automatically installed if you don't have it)

Installation

Note: You must have pip installed

Installation is easy, just a simple one-liner.

wget -qO - https://raw.githubusercontent.com/stautonico/python-color-scripts/main/install | python

Updating

This script has a built-in updater.

To update, simply:

python-colorscript --update

If a new version exists, it will automatically install.

Usage

The simplest way to get started is just to type python-colorscript in your terminal to display a random artwork!

Command Options

usage: python-colorscript [-h] [--16] [--256] [--left-padding LEFT_PADDING] [--top-padding TOP_PADDING] [--art ART]
                          [--list] [--random-color-mode] [--ignore-distro] [--blacklist BLACKLIST] [--version]
                          [--update] [--uninstall]

Draw some ASCII art!

optional arguments:
  -h, --help            show this help message and exit
  --16                  Draw in 16 colors mode
  --256                 Draw in 256 colors mode
  --left-padding LEFT_PADDING, -l LEFT_PADDING
                        Amount of space to add to the left side of the art
  --top-padding TOP_PADDING, -t TOP_PADDING
                        Amount of space to add to the top of the art
  --art ART             Draw a specific piece of art. View all using --list
  --list                List the names of all available art pieces
  --random-color-mode, -r
                        Use a random color mode
  --ignore-distro, -i   Show distro specific artworks on all distros
  --blacklist BLACKLIST, -b BLACKLIST
                        Remove specific artworks from random pool. Note: Multiple items need to be surrounded by quotes
  --add-art             Interactively add new art
  --version, -V         Show version information
  --update              Try to update to the latest version
  --uninstall           Uninstall the script from your system

and more secret arguments that you'll just have to discover on your own!

Note that in the 8 and 16 color modes, your terminal's color scheme is used, which may result in strange-looking artwork depending on the colors you have set. For the "best" visual representation, use the 256 color mode by including --256 in your command

Recommended Use Case

You can add this file to the end of your .zshrc or .bashrc to get some ASCII artwork every time you open a terminal!

Uninstallation

To uninstall, simply:

python-colorscript --uninstall

Note: Uninstalling does not remove ~/.config/python-colorscript/, so manual changes will be saved next time you install. If you wish to remove it, you can manually do so after uninstalling.

Adding New Art

There are two ways to add new art: interactively and via a JSON file.

Regardless of the mode, you need to start by using kui's amazing ANSI Pixels tool to draw the art and get the base64 representation.

  1. Navigate to ANSI Pixels
  2. Draw the art you want to be displayed (keep it to a smaller resolution because larger images will break on smaller terminals)

Now the steps change depending on which method you use.

If you want to edit the config file directly:

  1. Copy the link generated by the site (the text above the artwork that starts with "python -c")
  2. Extract the base64 portion of the link (it is the part in quotes after "ansi-pixels.py or after the '#' in the URL bar)"
  3. Add it to the ~/.config/python-colorscript/art.json file (use the existing artwork entries as a template)

Note: The format of art.json is as follows:

{
  "artwork_name": {
    "8": "the base64 for the artwork in 8 color mode",
    "16": "the base64 for the artwork in 16 color mode",
    "256": "the base64 for the artwork in 256 color mode"
  }
}

Also, note that at least one color mode is required, but not all three need to be specified.

Otherwise, you can launch the program with the --add-art flag

  1. Launch the program with the --add-art flag
  2. Enter the name of the artwork and hit Enter
  3. Enter the URL for the artwork in 8 color mode and hit Enter
  4. Enter the URL for the artwork in 16 color mode and hit Enter
  5. Enter the URL for the artwork in 256 color mode and hit Enter

You can add your art to this repo by submitting a pull request with your changes. Note that any art that is submitted in a pull request needs to:

  • Be your own work (or have credits in the readme)
  • Must have art for all three color modes (to make sure it works on all terminals)

Troubleshooting

ZSH Completions Not Working

  • Make sure /usr/share/zsh/functions/Completion/Unix/_python-colorscript exists
  • Add autoload -U compinit && compinit to your .zshrc

"command not found"

  • Make sure you have ~/.local/bin in your $PATH (the executable is installed here)
  • Manually verify that ~/.local/bin/python-colorscript exists and is executable
    • Check with stat ~/.local/bin/python-colorscript

"command 'python' not found"

  • In this case, python is either not installed or not an alias of python3
  • Try running the one liner with python3 instead of python AKA try:
    • wget -qO - https://raw.githubusercontent.com/stautonico/python-color-scripts/main/install | python3

Credits

Almost none of this is my original work, so all the credit belongs to these people:

Art Credits

About

ASCII art for your terminal! A rework of DistroTube(Derek Taylor)'s color scripts

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages