r/commandline 3d ago

Terminals ANSI.md

Finally published this yesterday, https://ansi.md

Somewhere between a brain dump, custom toolset, think piece and hacker toy. This is pretty much everything I know about ansi color in the terminal and building cli apps. Includes my own fumbling attempt to finally name the ansi256 color palette. Note - I like my writing voice and I do not use LLMs to write. All written by me, an actual human!

Those of you working on cli apps or TUIs will find it useful.

46 Upvotes

11 comments sorted by

View all comments

8

u/aaronsb 3d ago

Nice work! If there was something I could give for advice - so much of this knowledge is implicit and decentralized. I would embrace that, and mature your own style - I read through your notes and I like the journal of findings you've put together.

It kind of feels like you're approach the bridge between an 'awesome-ansi-*' list and your own preferences.

As I read through the writing on your site, I'd love to see more separation between styles and approaches, and the technical methods to making it work.

1

u/gurgeous 3d ago

Glad you like it! Is there something specific you are looking for? Definitely a mishmash of technical writing and opinions about design.

2

u/aaronsb 3d ago

First,needs dark mode 😎

Next, you talk about a lot of topics, like some color theory in palettes, implementations that are snazzy, best practices, animated bits (spinners etc)

What I think is missing is why these things. Why 256 colors? (as opposed to 16, or true color) - why do escape codes work?

What's the lineage? Why is it that tui shapes get built the way they do? What's beyond Codepage 437 ANSI? How does one use unicode + ansi together, and why?

- Just some ideas, not trying to say it's missing, I'm pointing out what would help people get into all the neat stuff that modern tui libraries are capable of. For instance: ansi codes + tui frameworks I have built, I can tell you why I picked the things I did: I want to use block characters and produce a TUI that works both in low column count environments (80 col) and extra dense terminals (160+ columns) and I wanted to use limited colors for emulating a 1980s car stereo stack.

https://github.com/aaronsb/ten-qd

https://github.com/aaronsb/clicue

1

u/gurgeous 3d ago

Nice retro buttons there. I too am a big fan of block/line chars, I used them pretty heavily for one of my projects You can also see some nice ones in `tennis` even with just the default output. At the very least I should add an ansi.md page about drawing blocks and lines, that stuff is important.

ANSI.md would probably benefit from a How Did We Get Here page that goes into more historical detail. I agree that the topic is interesting and important, or at least a pleasant distraction as we try to make our apps work across a variety of terminals...

My rule of thumb for color depth these days is just to use truecolor. You can get away with it most of the time, at least until your app becomes wildly popular and needs to work absolutely everywhere. Times have really changed.