Show HN: Rich-CLI – A CLI toolbox for highlighting, Markdown, JSON and rich text
github.com
github.com
This is a command line tool I’ve been working on for rendering various types of content in the terminal.
The core functionality is syntax highlighting with line numbers and indent guides.
It can render Markdown (commonmark), and does a reasonable job given the limitations of Terminal emulators.
It can render JSON with syntax highlighting.
Finally it can display general purpose rich text with “console markup” (like bbcode).
All of the above can have borders, styles, alignment applied independently.
This was written hastily, the majority of it came together over a single weekend. This is because it was built with Rich (a Python library which I am also the author of) which does the heavy lifting.
Currently you can install it as a Python package, but I plan on adding it to other channels so you can get it via your preferred package manager.
I know there are some excellent apps with equivalent features but I’m hoping this will become a versatile tool for developers (in particular). I’ll be adding more formats in the future.
Hope you find it interesting. I’ll be around for a while to answer questions.
Not sure how to go about designing a CLI tool that adds progress bars to things that might involve executing other shell commands though - I guess "pv" is good prior art here.
$ rich --print "\n hello world"
but it just returned
\n hello world
Also, where can I find the list of emoji and the correspondent ":description:"?
Does this support paging? I could see myself using this a lot for markdown files if it does.
And do you plan on supporting RST files?
Are there any plans to make it easy to generate the Rich tables from the command line? Such as from CSV, TSV, JSON/L, or even SQLite databases?
#!/bin/bash
rich "Starting process" --rule --rule-style "red"
# ... do some stuff
rich "Process [b]complete[/b]" -p -c --padding 1 --style "on blue" echo "$(tput setaf 1)Starting process$(tput sgr0)"
echo " $(tput setaf 2)Process $(tput bold)complete$(tput sgr0)"$ rich "hello world" -p -a <TAB> ...
Where "..." is all the possible values that can be taken in.