artty

package module
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

README

arTTY

🍪 Buy me a cookie

Go Report Card

What is this?

Art for your TTY.

Screenshot

How to install

Open a terminal and run the following:

$ go install --ldflags "-s -w" --trimpath \
    gitlab.com/mjwhitta/artty/cmd/arTTY@latest

Or install from source:

$ git clone https://gitlab.com/mjwhitta/artty.git
$ cd artty
$ git submodule update --init
$ make install

Note: make install will install to $HOME/.local/bin.

How to use

I typically add something like the following to the end of my bash/zsh configs:

[[ -z $(command -v arTTY) ]] || arTTY

Then I create an arTTY config using something like one of the following commands:

$ arTTY -c -f --fit -r -p -s --save
$ arTTY -c -e "emerald|III|shiny" --fit -m pokemon -p -r -s --save
$ arTTY -c -f --fit -m "megaman-battle-network" -p -r -s --save
$ arTTY -c --fit -m portal -p -r -s --save
$ arTTY -c -f -p -s --save linux-arch
$ arTTY -c --fit -p -s --save legend-of-zelda-majoras-mask
$ arTTY -c --fit -m "street-fighter-3" -p -r -s --save

Use the --ls flags to see all included art. Occasionally you may want to run arTTY --update to download any new art.

Additionally, the system info portion is configurable.

Tab completion

You can add one of the below to your $HOME/.bashrc or $HOME/.zshrc to get tab completion.

bash
if [[ -n $(command -v arTTY) ]]; then
    _arTTY_complete() {
        mapfile -t COMPREPLY < <(arTTY --ls -m "^$2" -p)
    }
    complete -F _arTTY_complete arTTY
fi
zsh
if [[ -n $(command -v arTTY) ]]; then
    compdef _gnu_generic arTTY
    _arTTY_complete() { reply=($(arTTY --ls -p)); }
    compctl -K _arTTY_complete arTTY
fi

Generating your own art

ArTTY can generate source code from images too. It will automatically determine the size, but you can specify a size manually by appending _WIDTHxHEIGHT to the filename. It uses the filename to name the art unless you manually specify one. It will then cache any json files in the $HOME/.config/arTTY/arTTY_json directory.

By default this will generate a JSON file and refresh the cache. If you want to just see the JSON file, or generate source code for another language, you can use the --format flag.

Examples
$ arTTY -g my-art-name.png
$ arTTY -g my-art-name_WIDTHxHEIGHT.png
$ arTTY -g some_image.png my-art-name
$ arTTY --format bash -g my-art-name.png
$ arTTY --format go -g my-art-name.png
$ arTTY --format json -g my-art-name.png
$ arTTY --format python -g my-art-name.png
$ arTTY --format ruby -g my-art-name.png

This will traverse a WIDTH by HEIGHT grid and sample the color inside each cell. It will then generate the necessary json data. This works best with sprites, however, it can parse any image this way.

TODO

Documentation

Index

Constants

View Source
const Version = "1.0.5"

Version is the package version

Variables

View Source
var Cache = cache.New(Version)

Cache related vars

Functions

func BruceSchneier added in v0.12.5

func BruceSchneier() string

BruceSchneier will parse the HTML response from https://schneierfacts.com and return the provided "fact".

func DevExcuse

func DevExcuse() string

DevExcuse will parse the HTML response from http://developerexcuses.com and return the provided excuse.

func Filter

func Filter(
	match string,
	exclude string,
	w int,
	h int,
) ([]string, error)

Filter will apply match and exclude filters and return a list of art that fits the specified width and height.

func Fortune

func Fortune() string

Fortune will return the output from the fortune command if it is installed.

func Get

func Get(name string) *art.Art

Get will return the Art matching the provided name.

func TermSize added in v0.10.10

func TermSize() (w int, h int)

TermSize will return the size of the terminal.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL