Skip to content

0xHaru/Nerd-Color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nerd-Color

A simple CLI colorizer.

Description

Nerd-Color can be used as command line interface application or as a library to colorize text using the standard 16 colors (ANSI escape codes) or using true colors.

The former uses colors such as "red", "green, "blue" and will respect the terminal color scheme.

The latter uses colors such as "#FF0000" "00FF00" "#0000FF" and will display them regardless of the terminal color scheme.

More info here:

Prerequisites

Installation

pip install Nerd-Color

Usage

CLI

Basic usage:

<text> | nerdcolor <parameters>

Example:

cat dummy.txt | nerdcolor -t -d word -p dracula

Other examples:

Full versions:

	1) nerdcolor --ansi --delimiter line --bold --palette red green blue
	2) nerdcolor --true --delimiter word --palette dracula
	3) nerdcolor --true --delimiter char --palette "#8FBCBB" "#88C0D0" "#81A1C1" "#5E81AC"

Shortened versions:

	1) nerdcolor -a -b -p red green blue
	2) nerdcolor -t -d word -p dracula
	3) nerdcolor -t -d char -p "#8FBCBB" "#88C0D0" "#81A1C1" "#5E81AC"

Library

Full usage: usage.py

from nerdcolor.nerdcolor import Colorscheme

string = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""

scheme_1 = Colorscheme(["red", "green", "blue"], "ansi", delimiter="line")
scheme_2 = Colorscheme(["dracula"], "true", delimiter="word", bold=True)

colors = [
    "#EFFFFB",
    "#50D890",
    "#4F98CA",
    "#7874F2",
]

scheme_3 = Colorscheme(colors, "true", delimiter="char", bold=True)

print(scheme_1.colorize(string), "\n")
print(scheme_2.colorize(string), "\n")
print(scheme_3.colorize(string))

Config

To add custom color schemes the user has to add them to the SCHEMES dictionary in nerdcolor.py.

This command will output the full path of the file:

pip show Nerd-Color | grep 'Location' | grep -o -E '[/].+' | xargs printf '%s/nerdcolor/nerdcolor.py\n'

Color schemes

Nerd-Color currently has 25 predefined color schemes.

You can print them using this snippet:

from nerdcolor.nerdcolor import SCHEMES, Colorscheme

for key in SCHEMES.keys():
    scheme = Colorscheme([key], "true", delimiter="word")
    string = f"{key}: {SCHEMES[key]}"
    print(scheme.colorize(string))

Links

github.com/uloco/theme-bluloco-dark

github.com/dracula/dracula-theme

github.com/pawelgrzybek/gatito-theme

github.com/Mayccoll/Gogh

github.com/arcticicestudio/nord

github.com/Binaryify/OneDark-Pro

github.com/enkia/tokyo-night-vscode-theme

github.com/tomasiser/vim-code-dark

code.visualstudio.com

monokai.pro

colorhunt.co/palettes

License

This project uses the following license: GPLv3.