Rich: A Python library for rich text and formatting in the terminal
github.com
github.com
When called on an object, it pretty prints a list of its public attributes (though you can also request private and dunder attributes) [2]. It can also be called on a class or function; it'll then pretty print the docstrings, parameters with types, methods, etc. It's great for debugging and for starting to code with libraries you're not familiar with, don't have comprehensive documentation, or have some dynamic aspect.
In a similar vein, `objexplore` [3] is another library that lets you dive into an object's nested attributes to understand how it's laid out.
In interactive debugging sessions I often find these to be more useful than the IDE's features which provide similar functionality.
[1] https://rich.readthedocs.io/en/stable/reference/init.html#ri...
[2] https://i2.paste.pics/798cff2903f6b3351289a24c839d4f44.png
python -m textual.app
is so satisfying. You get web like layout dynamicism without the whole browser stack.cat, ls, etc.. just work, bat has to be installed, and I have a pretty high threshold for a utility to be so vital for me that I absolutely have to install it in every Unix box I work.
That way, I don't have manually install everything for new systems or when I'm doing a clean install on one of my existing systems.
I just tested simple concatenation and bat is over 10x slower:
$ time cat 1GiB 1GiB 1GiB 1GiB >/dev/null
real 0m0.414s
user 0m0.014s
sys 0m0.400s
$ time bat 1GiB 1GiB 1GiB 1GiB >/dev/null
real 0m4.257s
user 0m1.659s
sys 0m2.594s
Seems like a lot of these "modern" replacements lose what the original simpler utils do well.Seems like a recurring thing[0] with the modern alternatives.
I have limited focus as is, if I can make mental search easier, it takes a noticeable cognitive load off.
What rubs me wrong is the collective halfassedness of it all. When less craps out ANSI codes, when the terminal tears and your cursor is offset because it got confused about control characters, dozens of different color configs rather than a system theme.
There was this time in the Linux dark ages, red hat Linux 2 era. The enlightenment window manager was considered part of protocol GNOME, there were a lot of really exotic or organic themes, skinning was the hotness. Windows couldn’t do it. Ux be damned, if you wanted your desktop to look like some sort of demonic rune set, you could do it. Rationality, ux, consistency, etc took over. Cli skinning never seems to grow that way. I keep hoping some hacker that doesn’t know better will write a new terminal emulator, replaces ANSI codes with some minimal html and invents console css and the community embraces it.
Even those layers and layers don't _have to_ slow things down. Check the refterm "debacle" ([2] for the context, [0, 1] as Muratori's answer to it). It's just the way things are usually programmed doesn't care about performance and how fast things really can be. I sometimes wonder in we're not due for a massive round of optimization on a couple of the layers that we're used to using/depend on.
[0] https://www.youtube.com/watch?v=hxM8QmyZXtg
It’s a gigantic task, but when I see new folks reimplementing “ls” as a “modern replacement” and I do find value with many of these tools (I love ripgrep and bat, among others) I hope/wish someone felt the itch to tackle this.
Someone has tried on macOS. It hasn't really seen mass uptake though.
Long abandoned but I’d love something like this. Someone I know tried to revive it but Node has changed so much that they gave up.
I would donate to an effort to revive it.
Mainframes and minis modeled many apps as “screens.” Some blend of the streaming style text we have now, with screens, with a new and understood set of protocols that are similar to what we use everywhere else. I think some sort of table in console html would be about my limit, various “modern shells” already support tabular data with, like, their three magic built ins.
Not something I use, I tend to just `xdg-open .` to view them in Nautilus/EOG.
I have been learning Powershell and given its object based nature, a PowerTerm that extended PowerShell in this way seems like an obvious extension.
Of course, my next thought is, why do you not build it yourself? LOL
Shallow 3D UIs might be an opportunity for spring cleaning? Playing with them years ago, my stack was full-screen browser glued to kernel evdev - the rest of the usual stack (wm, libinput, much of X, browser input events) was easier to replace than adapt.
Or at least as one perhaps-modal option.
personally i hated it, it was laggy, slow and unstable... made a fast linux machine feel like a slow windows thing. i think i ran windowmaker at the time with a color scheme that reminded me of an old indy i used to have. it looked good and stayed out of my way...
Many 'modern' CLI prompts look like an emoji trashheap affixed with a lot of status information that eats up space and isn't directly actionable.
Example: https://raw.githubusercontent.com/csdvrx/bash-timestamping-s...
[0]: https://github.com/romkatv/powerlevel10k
[1]: https://starship.rs/
EDIT: Just noticed a peer comment below captures the issues with ANSI way better than I did.
Not sure how people put up with all that powerline stuff either, or multi-line PS1s that have shit on either side. Reminds me of geocities.
Show HN: Python lib for rich text, markdown, tables, etc. in the terminal (https://news.ycombinator.com/item?id=23070821 2020, 47 comments)
Related discussion:
Textual: a Python text user interface with Rich as the renderer (https://news.ycombinator.com/item?id=27526031 7 months ago, 21 comments)
Stack traces are presented in a gorgeous fashion, log.debug lines have lots of great meta data with them. I almost always start new projects with those as my first imports.
It got me thinking that, atleast for technology developers, this is the ideal use of twitter. An uncensored "thoughtstream". Some tools to mine that and extract lessons might be an interesting project.
1 tabulate: helps render ASCII tables in various formats (https://github.com/astanin/python-tabulate)
2. typer: write cli commands by decorating python functions. It uses type annotations to automatically parse input (https://typer.tiangolo.com/)
We're using both of those in our Kubernetes troubleshooting tool (https://robusta.dev). Going to look at adding Rich too
We're actually sending data to both terminal and non terminal destinations like Slack/MsTeams. We render to html or markdown when we can, but sometimes we have to fall back to ASCII.
If you're curious, you can see the way we're using tabulate here:
https://docs.robusta.dev/master/developer-guide/actions/find...
The UI would be similar to this: https://user-images.githubusercontent.com/700826/113683873-a...
That said it doesn't push "input controls" quite to the extreme Rich/Textual do for UI controls, but it might be a starting point to look into.
Well, you can tell from the way I use nGrok, I'm a jq man, no time for awk