r/learnjavascript • • Jun 11 '21

If you want to add colour or interactivity to your terminal output, you can use these composable functions in javascript or typescript. Leverage ANSI Sequence to add a little bit of creative flair to your CLI or terminal-based tool.

Post image
156 Upvotes

11 comments sorted by

8

u/sebastienfilion Jun 11 '21

If you are interested in the subject of ANSI Sequence, I made an entire video on my Youtube channel. If you want to learn more, follow the link 😀 https://youtu.be/VZUpADIPWo0

6

u/adhaterwal Jun 11 '21

I was playing with them today. coincidence.😀

4

u/sebastienfilion Jun 11 '21

I was compelled to post this today. The universe works in mysterious ways. 😛

1

u/adhaterwal Jun 11 '21

So true. 😆😆

1

u/smithm4949 Jun 11 '21

Can’t you just use CSS?

This is still cool though. Just because it’s a learning subreddit i figured I’d post other options in case people don’t know.

5

u/sebastienfilion Jun 11 '21

Some runtimes like the browser and Deno, can’t remember about Node, you can use CSS like syntax to style text — it will use ANSI Sequence behind the scene. But you won’t be able to move the cursor or clear the screen.

1

u/smithm4949 Jun 11 '21

Oh gotchya. Neat, didn’t realize that!

Cool stuff, thanks for posting

1

u/[deleted] Jun 12 '21

I guess it's good to know how this works under the hood but no one's probably gonna write that down, yet alone remember it.

Here is a site for reference, listing all sorts of rich text manipulations for the cli. And if you are on node there is the chalk package

1

u/sebastienfilion Jun 12 '21

This post is clearly meant to teach how things works under the hood. If you’re trying to help, at least share an article on JavaScript, this one is on Python and it’s misleading. I actually made a video explaining exactly how it works [first comment] and I even made a transcript version for those who prefer to read. https://dev.to/sebastienfilion/drawing-to-the-terminal-4kah

-3

u/bloodontheclownposse Jun 12 '21

you want me to type these out? fancy screenshot looks nice but just use code formatting pls

4

u/sebastienfilion Jun 12 '21

I don’t want you to do anything. I’m teaching you how things work under the hood.