May 10, 2020 will

Real working hyperlinks in the terminal with Rich

Since releasing Rich 1.0.0 I've discovered that terminals support hyperlinks. And I don't mean the helpful highlighting of URLs that most terminals do, I mean actual HTML-like hyperlinks that launch a browser.

This was news to me, as I've never seen this feature in the wild. I just had to add it to Rich. The easiest way to output hyperlinks is via console markup. Here's a simple example:

>>> from rich import print
>>> print("Visit my [link=]blog[/link]!")

This will output the text "Visit my blog!" in the terminal where the word "blog" is a clickable link that opens the browser.

This is a relatively new (2017) addition to the spec, so it isn't supported on all terminal apps. If your terminal doesn't support hyperlinks then the link won't be clickable, but you will see the text as normal.

I've also added this to the the markdown renderer, which will now render working links. This is best demonstrated in a video:

Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google]( > This is a quote > ```python import this ```
your comment will be previewed here
Durai Murugan

i tried this from rich import print print("Visit my [link=]blog[/link]!")but it is not working

Will McGugan

Did you see the text?

If it wasn't clickable it may be because your terminal doesn't support links.

Wasi Master

Is there any way to know if the terminal supports links or not?

Thombre Janhvi

yes, it is not clickable in my case also do you have any solution

Sorin Sbarnea

Once with get merged and release we should expect to also see hyperlinks working in vscode own terminal. Until then, feel free to enjoy them in other terminals. The good part is that when terminal does not support them, they just see plain text that cannot be clicked, no garbage on the screen.

Jonathan Crall

The rich library continues to impress.