How to Use the pastel Command in Linux to Generate, Analyse, and Convert Colours

Working with colour palettes, hex codes, and colour conversions in Linux often involves juggling multiple web tools or opening full graphics software. The pastel command Linux utility solves this problem by providing a command-line tool dedicated to generating, converting, analysing, and manipulating colours directly inside your terminal.

What Is the pastel Command in Linux?

Written in Rust, pastel is an open-source CLI utility that parses colours from various colour spaces—including RGB, HSL, CIELAB, and hexadecimal notation. It renders true-colour swatches directly in your terminal emulator, allowing developers, designers, and system administrators to preview and fine-tune colour schemes for scripts, websites, terminal themes, and UI assets without leaving the shell.

How to Install pastel on Linux

Because pastel is distributed across major repositories and package managers, installation is straightforward across standard distributions.

Installing on Debian and Ubuntu

On modern Debian and Ubuntu distributions, install the pre-compiled binary package directly via APT:

sudo apt update
sudo apt install pastel

If your distribution’s default package is older, download the latest .deb release package from GitHub and install it using dpkg:

sudo dpkg -i pastel_*_amd64.deb

Installing on Arch Linux and Fedora

On Arch Linux, install pastel from the official extra repository:

sudo pacman -S pastel

On Fedora, install it through DNF:

sudo dnf install pastel

Installing via Cargo

If you prefer building from source or managing CLI tools with Rust’s package manager, execute:

cargo install pastel

Inspecting and Converting Colour Spaces

One of the primary benefits of pastel is inspecting any given colour and instantly viewing its representation across every standard colour model.

Viewing Detailed Colour Properties

To inspect a colour, pass any recognised colour name, hex string, or RGB value to the color sub-command:

pastel color "#2563eb"

This command prints an interactive terminal swatch alongside detailed metrics: hexadecimal, RGB percentages, HSL coordinates, HSV values, CIELAB coordinates, and Luminance calculations.

Converting Between Hex, RGB, and HSL

When writing CSS or configuring terminal themes, you frequently need to convert colour formats on the fly. You can convert values cleanly using dedicated format flags:

# Convert a hex value to RGB
pastel format rgb "#3b82f6"

# Convert an RGB value to HSL
pastel format hsl "rgb(59, 130, 246)"

# Convert an HSL value to Hex
pastel format hex "hsl(217, 91%, 60%)"

Generating Colour Palettes and Gradients

Beyond simple conversions, pastel excels at generating harmonious palettes and colour gradients.

Generating Random Harmonious Colours

Generate a set of distinct, aesthetically balanced random colours with the random sub-command:

pastel random -n 5

You can also constrain randomness by specifying perceptual distance or light/dark themes:

pastel random --strategy distinct -n 6

Creating Smooth Gradients

To interpolate between two colours and produce a stepped gradient across colour spaces, use the gradient sub-command:

pastel gradient "#1e3a8a" "#93c5fd" -n 8

This renders eight intermediary colour swatches spanning from deep navy to soft pastel blue.

Manipulating Colours with Sub-Commands

You can adjust brightness, saturation, and hue dynamically using pipeline operations.

Lightening and Darkening

To lighten or darken a base colour by a specified percentage:

# Lighten a shade by 15%
pastel lighten 0.15 "#1f2937"

# Darken a vibrant colour by 20%
pastel darken 0.20 "#10b981"

Adjusting Saturation and Hue

Fine-tune vibrancy or rotate colour angles along the colour wheel:

# Desaturate a colour by 30%
pastel desaturate 0.3 "#ec4899"

# Rotate hue by 180 degrees to find the complementary colour
pastel rotate 180 "#f59e0b"

Piping pastel Outputs in Shell Scripts

Because pastel respects standard Unix stream pipelines, you can chain commands together to build sophisticated automation workflows:

pastel random -n 4 | pastel lighten 0.1 | pastel format hex

This pipeline generates four distinct colours, lightens each value by 10 percent, and outputs pure hexadecimal strings ready to be injected into template configuration files.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.