
Show HN: Python lib for rich text, markdown, tables, etc. in the terminal - willm
https://github.com/willmcgugan/rich
======
rozab
Other great tools in the python terminal sphere are colorama, blessings and
urwid.

Colorama is just for cross platform colouring, blessings is a very elegant
wrapper over curses which is still useful for not-fullscreen things, and urwid
is a full-blown widget library for TUI stuff.

~~~
jquast
please also consider blessed, an API-compatible fork of blessings that adds
Windows 10 support, 24-bit color, keyboard input, and more.
[https://blessed.readthedocs.io/en/latest/intro.html#brief-
ov...](https://blessed.readthedocs.io/en/latest/intro.html#brief-overview)

------
madhadron
Lovely work, and I feel sad that this kind of labor inside a teletype emulator
is something we consider anything but niche nostalgia in 2020.

~~~
willm
I felt for sure we would have Minority Report interfaces by 2020, but looks
like we're stuck with terminals until retirement.

------
kstrauser
I'm blown away. That's amazingly gorgeous!

~~~
billowycoat
Thanks!

------
ashton314
Reminds me of my own Marked-Man utility [1], but this is _way_ prettier.
Definitely will have to check this out. Maybe I'll redo marked-man with this
lib.

[1]: [https://github.com/ashton314/marked-
man](https://github.com/ashton314/marked-man)

------
dec0dedab0de
This looks great. I love stuff like this, especially that it is cross
platform. One thing that would be nice to see is a list of which terminals are
supported, or at least what the various terminals support.

~~~
billowycoat
Thanks. Should work with any xterm compatible terminal, and Windows legacy
terminal.

------
_e
Perfect timing.

I was looking at Urwid ([http://urwid.org/](http://urwid.org/)) last night for
a new project. Urwid is a console user interface library for python.

------
20wenty
It's beautiful, but what I love most is the detailed README. Thank you for the
attention to detail.

------
jarpineh
I'll add my grateful thanks.

Rich has already become my go-to tool for various Python stuff. I use these
days Code's Python file with notebook cell comments. With this I can use
console and Jupyter Notebook style rendering depending on wether I'm using
regular IPython or Code's Interactive Window. I'm adapting my console printing
to leverage Rich's features for Django querysets and other objects I'm dealing
with. Rich gives me poor man's Jupyter Notebook widgets. Now I don't need to
switch to ipynb files for browser based JS widgets much at all.

~~~
willm
Good to hear its useful to you. :)

------
maest
Related to this - is there a way to have a similar rich-styling library
designed for email outputs?

I have some daily reports generated by a python script via cron. The script
currently outputs plaintext and the email just adds <pre> tags around the
output, for formatting purposes. Some spicier formatting would be nice.

~~~
billowycoat
There is an method to export the terminal as HTML. See
[https://rich.readthedocs.io/en/latest/reference/console.html...](https://rich.readthedocs.io/en/latest/reference/console.html#rich.console.Console.export_html)

Here is an example of the output
[https://rich.readthedocs.io/en/latest/appendix/colors.html](https://rich.readthedocs.io/en/latest/appendix/colors.html)

------
1337shadow
Excellent ! Really love the traceback coloration, would love to have that
enabled by default, should probably check pythonrc if it can hook that up.
Also, RST support would be nice to render docstrings. Also, nice sphinx docs
dir, perhaps enable rtfd.io or something that will publish them somewhere as
HTML ?

~~~
billowycoat
Some good ideas there. I’m hoping that people will build such things on top of
Rich. I don’t want to add much more to the core lib...

~~~
1337shadow
Well I have just finished a sub-optimal color implementation with also my own
print() implementation in
[https://yourlabs.io/oss/cli2](https://yourlabs.io/oss/cli2) and I'd be
willing to throw another week at it, but didn't really identify how rich could
help exactly, if you want to open a ticket there then we can start a
discussion

See some screenshots:

[https://yourlabs.io/oss/cli2/uploads/1bb0d9278047b4656f97ebb...](https://yourlabs.io/oss/cli2/uploads/1bb0d9278047b4656f97ebbfe3f59b19/2020-05-05-112049_1026x700_scrot.png)

[https://yourlabs.io/oss/cli2/uploads/8692ed0815082af8a903619...](https://yourlabs.io/oss/cli2/uploads/8692ed0815082af8a903619a05ec3ce1/2020-05-05-112102_1051x397_scrot.png)

Still working on the rendering part

Keep up the great work

------
djsumdog
I have a short block of code I put in a lot of projects with just color output
and formatting. But now I really want to start using this.

I like that it's cross platform and you can do very simple things or very
complex formatting. This is super neat.

------
hagy
This is great! Will certainly be using it in all my command line tools and
scripts. Particularly the log handler. Also, like how it has special support
for Jupyter notebooks.

Thanks for developing this.

------
ablekh
Excellent work, kudos! By the way, as a freelance software developer, do you
work with Flask or other frameworks (instead of Django), if needed?

~~~
willm
Thanks. Yeah, I've worked with a variety of web frameworks, including Flask.

~~~
ablekh
My pleasure. Great, will keep it in mind for potential future collaboration.
;-)

------
danso
Very cool, looks nice enough to try throwing it in my projects right now
(since I've never settled on a proper output formatter).

------
op03
Really cool esp the table stuff and pretty printing list and dicts in color.

This might be useful to integrate into pandas, BeautifulSoup etc

------
alexpetralia
Is anyone able to get this working in PyCharm?

I can get it working on both a shell Python and iPython console, but not in
the PyCharm console.

~~~
billowycoat
Never tried PyCharm. Do you know if it handles Color normally?

------
Mizza
This really rocks, man, can't wait to use it. I used to use 'Clint', but this
is even more robust.

------
simonw
This is SO cool! Amazing collection of features, really clean API design. I
had no idea how much I wanted this.

------
trogdorunique
Came to echo many others here - great work and fantastic attention to detail.
Thanks for your effort.

~~~
willm
Gracias

------
ipsum2
Looks great! Any chances of curses or other TUI integration, or is that out of
scope for the project?

~~~
billowycoat
I had a vague notion of building some kind of UI on top of Rich, but tbh I
want to reclaim some spare time after 1.0.

~~~
noah_buddy
Thanks for making this and thanks for making time to take care of yourself!
Cultivating your creative energies is an achievement in itself.

------
tvb12
It would be awesome for manpages and vim helpfiles to have formatting and
color like this.

~~~
kmundnic
If you're willing to use zsh, there's an oh-my-zsh plugin to color the
manpages, and you can adjust the colors as described here [1].

[1]
[https://unix.stackexchange.com/questions/501156/personalize-...](https://unix.stackexchange.com/questions/501156/personalize-
colored-man-pages-zsh-plugin-colors)

~~~
tvb12
Thanks, I'll check this out.

------
dave_sullivan
This is awesome. I’ve used termcolor and urwid in the past, will give this a
shot.

------
gunshai
This is really cool! How did you even go about building something like this.

------
jpxw
Wow. That progress bar - I’m sold. Looking forward to trying it out

~~~
stonecharioteer
I've been using "rich" for last month and I love it. It makes nested progress
bars easy. There is still a lot left to desire but it is amaze balls.

------
kelsolaar
Awesome work, the Jupyter notebook support is really appreciated!

------
robifis
Absolutely love this. Will implement it in my CLI games.

~~~
willm
I'd love to see that! Tweet @willmcgugan when you have something :)

------
bobbydreamer
Right on time

