In this article we are going to take a look at Pastel. It is a free and open source command line tool for working with colors. We can convert colors from one format to another, display and analyze colors from the terminal and even use a color selector, among other possibilities.
This tool is written in Rust and it was launched a few days ago, but already contemplates quite a few use cases. With it we will be able to perform quick and simple operations such as converting between formats or choosing a color from the screen, to using it in scripts to generate color palettes or manipulate colors in themes.
The tool is compatible with many formats and color spaces different, including RGB, HSL, CIELAB, CIELCh, as well as 8-bit and 24-bit ANSI representations.
Download and install Pastel
In the versions page Cake we are going to find the binaries for Gnu / Linux (.DEB and generic) and macOS. Pastel can also be installed through Cargo. If you are interested, you can consult all installation options for more details from the project's GitHub page.
If you want to install this software on Ubuntu, just follow the instructions below. The first thing will be to open the terminal (Ctrl + Alt + T) and in it first use wget to download today's latest version of the .deb package:
wget "https://github.com/sharkdp/pastel/releases/download/v0.5.3/pastel_0.5.3_amd64.deb"
Once the download is finished, we can proceed to installation typing in the same terminal:
sudo dpkg -i pastel_0.5.3_amd64.deb
Options available in Pastel
When we use Pastel we will have a certain number of options or subcommands available. Among them we can find:
- color → Will show sample information about the given color.
- list → It will offer us a screen color name list availables.
- random → Generate a random color list.
- distinct → Will generate a set of visually distinct colors, maximizing the perceived color difference between color pairs.
- sort-by → Sort a list of colors by the given property.
- pick → Interactively select a screen color. Here it should be noted that for the color picker command to work, we will need to have an external color picker installed. Users will be able to choose between gpick, xcolor y colorpicker.
- format → Convert the given colors to a specific format.
- paint → Print text in color using ANSI escape sequences.
- gradient → Generate a color sequence interpolated between 'start' and 'stop'.
- mix → Create new colors by interpolating between two colors in the given space.
- SATURATED → Increase color saturation in a specific amount.
- desaturate → Decrease color saturation in a specific amount.
- lighten → Lightens the color in a specified amount.
- darken → Darken the color in a specified amount.
- rotate → Rotate the tone channel by the specified angle.
- complement → Get the complementary color (pitch rotated 180 °).
- gray → Create a gray shade from a given clarity.
- to gray → Fully desaturate a color (preserves luminance).
- textcolor → Returns a readable foreground text color (black or white) for a given background color.
Some usage examples
Format name will show us the name of a given color:
pastel format name 44cc11
El color subcommand is going to us display information about colors that we add in hexadecimal:
pastel color 0E5478 4ecdc4 c7f484
We will be able get two random colors using the random subcommand from the Pastel tool:
pastel random -n 2
When using the mix subcommand, We create a new color mixing red and blue (in this example) in RGB color space:
pastel mix --colorspace=RGB red blue
We will be able to use the sort-by command for sort 10 random colors by hue and format the output to hexadecimal:
pastel random -n 10 | pastel sort-by hue | pastel format hex
On its GitHub page the developer offers un Animated Demo GIF on how to use this tool.
uninstall
To eliminate this tool we will only have to open a terminal (Ctrl + Alt + T) and in it execute the following command:
sudo apt remove pastel