GitHub - sharkdp/pastel: A command-line tool to generate, analyze, convert and m...

 3 years ago
source link: https://github.com/sharkdp/pastel
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.



Build Status

pastel is a command-line tool to generate, analyze, convert and manipulate colors. It supports many different color formats and color spaces like RGB, HSL, CIELAB, CIELCh as well as ANSI 8-bit and 24-bit representations.

In action

pastel in action


Getting help

pastel provides a number of commands like saturate, mix or paint. To see a complete list, you can simply run


To get more information about a specific subcommand (say mix), you can call pastel mix -h or pastel help mix.


Many pastel commands can be composed by piping the output of one command to another, for example:

pastel random | pastel mix red | pastel lighten 0.2 | pastel format hex

Specifying colors

Colors can be specified in many different formats:

'rgb(119, 136, 153)'
'hsl(210, 14.3%, 53.3%)'

Colors can be passed as positional arguments, for example:

pastel lighten 0.2 orchid orange lawngreen

They can also be read from standard input. So this is equivalent:

printf "%s\n" orchid orange lawngreen | pastel lighten 0.2

You can also explicitly specify which colors you want to read from the input. For example, this mixes red (which is read from STDIN) with blue (which is passed on the command line):

pastel color red | pastel mix - blue

Use cases and demo

Converting colors from one format to another

pastel format hsl ff8000

Show and analyze colors on the terminal

pastel color "rgb(255,50,127)"

pastel color 556270 4ecdc4 c7f484 ff6b6b c44d58

Pick a color from somewhere on the screen

pastel pick

Generate a set of N visually distinct colors

pastel distinct 8

Get a list of all X11 / CSS color names

pastel list

Name a given color

pastel format name 44cc11

Print colorized text from a shell script

fg="$(pastel textcolor "$bg")"

pastel paint "$fg" --on "$bg" "well readable text"
pastel paint -n black --on red --bold "   ERROR!   "
echo " A serious error"

pastel paint -n black --on yellow --bold "  WARNING!  "
echo " A warning message"

pastel paint -n black --on limegreen --bold "    INFO    "
echo -n " Informational message with a "
echo -n "highlighted" | pastel paint -n default --underline
echo " word"


On Debian-based systems

You can download the latest Debian package from the release page and install it via dpkg:

wget "https://github.com/sharkdp/pastel/releases/download/v0.5.3/pastel_0.5.3_amd64.deb"
sudo dpkg -i pastel_0.5.3_amd64.deb

On Arch Linux

You can install pastel from the AUR package:

yay -S pastel

On other distributions

Check out the release page for binary builds.

Via cargo

If you have Rust 1.34 or higher, you can install pastel from source via cargo:

cargo install pastel


Interesting Wikipedia pages:

Color names:

Maximally distinct colors:

Other articles and videos:


Licensed under either of

at your option.

About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK