Most active commenters
  • Joker_vD(4)
  • teddyh(3)
  • Gormo(3)

102 points linsomniac | 32 comments | | HN request time: 3.872s | source | bottom
1. guessmyname ◴[] No.42180207[source]
People have been posting about these Charm projects for a few years now [1]. I think they look cool and, while I know they exist, I have never found myself in a position where I want to add them to my consumer-facing projects, nor even my personal projects. Does anyone have examples of (public) non-trivial Terminal programs that make use of these libraries?

[1] https://news.ycombinator.com/from?site=github.com/charmbrace...

replies(4): >>42180331 #>>42180696 #>>42181933 #>>42181934 #
2. woodruffw ◴[] No.42180331[source]
I similarly haven't used them, but vhs[1] looks very cool and useful (at least for my purposes, where I like to have lots of terminal demos in my documentation).

[1]: https://github.com/charmbracelet/vhs

3. ljouhet ◴[] No.42180334[source]
Great work: this tool will be really useful to me!

(Note: the "terminal animations" in github make the examples difficult to read.)

replies(1): >>42180454 #
4. EdSchouten ◴[] No.42180454[source]
Indeed. A screenshot of the resulting output would have been more useful.
replies(1): >>42181108 #
5. aumerle ◴[] No.42180636[source]
Or run

kitty --dump-commands program-whose-output-you-want-to-inspect

You can even save the --dump-commands output as edit it and then replay it with

kitty --dump-commands program > commands.txt

kitty --replay-commands commands.txt

6. terminaltrove ◴[] No.42180696[source]
We have a lot here which this list is exclusively TUI programs.

https://terminaltrove.com/categories/tui

and another list which are terminal tool of the week where some TUIs are complex, like dolphie, kaskade, trippy or pug for example.

https://terminaltrove.com/tool-of-the-week/

https://terminaltrove.com/dolphie/

https://terminaltrove.com/kaskade/

https://terminaltrove.com/trippy/

https://terminaltrove.com/pug/

7. jakeogh ◴[] No.42180898[source]
That's fantastic. Regarding the note about output detection, here is a short tcl script that attempts to trick the app into thinking it's writing to a terminal: https://github.com/jakeogh/colorpipe
8. frizlab ◴[] No.42181108{3}[source]
I literally took a screenshot of the animation to be able to read it yeah.
9. junon ◴[] No.42181358[source]
Another banger from Charm! Adding this to my tool belt for sure.
10. pointlessone ◴[] No.42181710[source]
Animated images in the readme are not a very good experience. I’m trying to read the output and make sense of it and it just blinks out. There’s no good reason to have animation here. We all know how text is typed in the terminal.
replies(2): >>42181882 #>>42181976 #
11. kreetx ◴[] No.42181882[source]
It shows the CLI use, seems pretty useful to me.
replies(1): >>42182327 #
12. bewuethr ◴[] No.42181933[source]
The GitHub CLI (https://cli.github.com/) uses Bubble Tea. There's no good way to find popular dependents, but you can browse https://github.com/charmbracelet/bubbletea/network/dependent... to see GitHub repos that import the module.
replies(1): >>42182470 #
13. oulipo ◴[] No.42181934[source]
I'm using `gum` in my personal shell scripts when I want basic interaction (show a list, checkboxes, etc)
14. arcanemachiner ◴[] No.42181976[source]
Good use case for Asciinema.

https://asciinema.org

https://github.com/asciinema/asciinema

EDIT: Looks like image generator might be from one of their own projects:

https://github.com/charmbracelet/vhs

replies(1): >>42183293 #
15. jchook ◴[] No.42182267[source]
Isn't it true that ANSI sequences can vary depending on the terminal emulator? Does this program account for that somehow?

In my shell scripts I often use `tput bold` etc instead of hardcoding the sequences.

replies(2): >>42182375 #>>42182672 #
16. Timwi ◴[] No.42182327{3}[source]
It doesn't show anything a still image that I can just read wouldn't also show. It has no upside and only downsides.
17. Joker_vD ◴[] No.42182375[source]
Well, yes, the meaning can depend, although many sequences have standardized meanings. The format of the sequences itself is also standardized but of course, the terminals don't need to use it either! There has been lots of terminals that use their own bespoke control sequences.

Still, nowadays people who write new terminal emulators tend to approach with "do what xterm/libvte does" attitude which is quite sensible: very few people use actual, physical terminals anymore, and the software ones are, well, are generally based on xterm or libvte (or that third library I keep forgetting).

And when was the last time terminfo has been updated anyhow? Not to mention that it lacks info about modern features such as e.g. the version of Unicode used/supported by the terminal.

replies(1): >>42182768 #
18. wlamartin ◴[] No.42182470{3}[source]
Just as a note, the GitHub CLI doesn't use bubbletea itself right now, though it does use other charm libraries such as lipgloss and glamour. That said, it's quite likely that at some point we will use huh for our prompting library, which does use bubbletea.
replies(1): >>42194798 #
19. binarybard ◴[] No.42182541[source]
Amazing!! Love seeing these tools from charmbracelet!

On a side note - VHS and mods have been super helpful to me.

20. teddyh ◴[] No.42182672[source]
> Isn't it true that ANSI sequences can vary depending on the terminal emulator?

Yes, historically, many terminals were not even ANSI compatible. That is why the terminfo database (and its predecessor termcap) exist; for programs to look at the TERM environment variable, use that to look up the terminal’s capabilities in terminfo, and see what the terminal can and cannot do, and then choose to output whatever sequences the terminal does support. Normally, a program uses yet another library, like ncurses, to do this, but you can do it yourself if you want to, like in a shell script or similar. Outputting raw escape codes is wrong, since the correct way is so very easy.

replies(1): >>42182781 #
21. zokier ◴[] No.42182768{3}[source]
> And when was the last time terminfo has been updated anyhow?

Two weeks ago?

https://lists.gnu.org/archive/html/bug-ncurses/2024-11/msg00...

> misc/terminfo.src | 40 ++++++++++++++++++++++++++++++-------

replies(1): >>42184354 #
22. Joker_vD ◴[] No.42182781{3}[source]
Don't forget to take care about the terminal code pages as well! Thankfully, terminfo tells you which commands to use when you want to print e.g. β, right?
replies(1): >>42182997 #
23. teddyh ◴[] No.42182997{4}[source]
The easy way is to either restrict yourself to ASCII, or to output raw characters in whatever encoding your locale (LC_CTYPE, LANG, etc.) specifies. If you want to get really fancy with ancient terminals, some of them have, for instance, line drawing characters (and, yes, sometimes things like β) hidden behind special escape sequences, which you can, IIRC, look up in terminfo.
replies(1): >>42184130 #
24. Gormo ◴[] No.42183293{3}[source]
Given the purpose of the tool, it seems like the most appropriate solution would be to use ANSI itself to animate the text.
replies(1): >>42183720 #
25. zellyn ◴[] No.42183720{4}[source]
Is that not what asciinema does?
replies(1): >>42189892 #
26. Joker_vD ◴[] No.42184130{5}[source]
So the "correct" way is not that easy, after all.

On the other hand, ignoring ancient terminals and simply pretending everything is color-enabled, VT-220 compatible, UTF-8 aware terminal emulator works well enough™ almost everywhere, including recent versions of Windows (which IIRC don't even have terminfo; not that it'd help since the legacy Windows console uses ioctl()-like interface instead of the escape sequences) — and is actually easy.

replies(1): >>42195656 #
27. Joker_vD ◴[] No.42184354{4}[source]
Wow, reading the history at the end of that file is... depressing. Well, good luck to Thomas E. Dickey, testing the vt/xterm-compatibiity of all the newfangled terminal emulators and maintaining capabilities on stuff like DJGPP in perpetuity.
replies(1): >>42189936 #
28. Gormo ◴[] No.42189892{5}[source]
No, asciinema uses a custom data format to store the terminal data, then uses custom JS to play it back within a web site.

I'm talking about just distributing ANSI files.

29. Gormo ◴[] No.42189936{5}[source]
What's depressing about it?
30. bewuethr ◴[] No.42194798{4}[source]
Oh wow, I could have sworn! Did you never use bubble tea and bubbles, or did you remove them at some point?
31. teddyh ◴[] No.42195656{6}[source]
Outputting UTF-8 to a UTF-8 locale is not easy? Most of this is automatically handled by appropriate libraries.

I.e. I would expect

  python3 -c 'print("\N{GREEK SMALL LETTER BETA}")'
to just work on any terminal, as Python does the right thing for you.