qjp - turn any json file into a quick TUI menu

23 points by pm


pm

Hi lobsters!

Here's a quick example ilustrating what this does. A very quick way of checking the news on lobsters:

curl -s "https://lobste.rs/hottest.json" | qjp -d title -o url | xargs lynx

I threw this together to scratch my own itch. Perhaps others will find it useful too.

awal

Nice work! I've a similar collection of scripts you might find useful. Admittedly I've not done a good job of publishing the source for reusability but you can see them here: https://codeberg.org/awal/quickactions.

The json_menu script reads json data from stdin, and presents a menu containing the passed data. Selected data is printed to stdout.

How the data is read and presented can be customized quickly with arguments passed as python expressions. Example:

$ echo '{"products":[{"id":1,"brand":"Lorem","title":"Ipsum..."}]}' \
    | json_menu choices=it.products \
                        formatter='f"#{it.id} #{it.brand} - #{it.title}"' \
                        value=it.id
andreypopp

I like these small tools. I always wished fzf supported JSON input "natively" — I think fzf can function as qjp but you'd need to encode the input in some form (with jq probably) before pipeline to fzf.