DEV Community

Cover image for Day 2: Terminal Gradients 🌈
Valeria
Valeria

Posted on

5 1

Day 2: Terminal Gradients 🌈

I love how colourful and sparkly everything is during holiday season, dont you? And today I'll share with you a tool that makes terminal a lot more festive as well!

Install the dependency, e.g:

deno add npm:gradient-string
Enter fullscreen mode Exit fullscreen mode

Create a script, e.g. main.ts:

import gradient from "npm:gradient-string";
console.log(gradient(["red", "green"])("Happy Holidays"));
Enter fullscreen mode Exit fullscreen mode

And run with deno -A main.ts:

Red to green gradient saying

And if that didn't impress you, try this one:

import { pastel } from "npm:gradient-string";

console.log(
  pastel.multiline(
    `
          .     .  .      +     .      .          .
     .       .      .     #       .           .
        .      .         ###            .      .      .
      .      .   "#:. .:##"##:. .:#"  .      .
          .      . "####"###"####"  .
       .     "#:.    .:#"###"#:.    .:#"  .        .       .
  .             "#########"#########"        .        .
        .    "#:.  "####"###"####"  .:#"   .       .
     .     .  "#######""##"##""#######"                  .
                ."##"#####"#####"##"           .      .
    .   "#:. ...  .:##"###"###"##:.  ... .:#"     .
      .     "#######"##"#####"##"#######"      .     .
    .    .     "#####""#######""#####"    .      .
            .     "      000      "    .     .
       .         .   .   000     .        .       .
.. .. ..................O000O........................ ...... ...`
  )
);

Enter fullscreen mode Exit fullscreen mode

Now, that's sight to behold:

Colourful pastel ASCII tree

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Sentry blog image

Identify what makes your TTFB high so you can fix it

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

Read more

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

I use lolcat for this. That doesn't integrate with node or anything, it's a plain old command, but that means I can pipe things to it like figlet or toilet, and you can even run a shell through it so everything is colourised as you type!

Collapse
 
valeriavg profile image
Valeria

Oh nice! Funny ruby library :) Thank you for sharing!

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay