Skip to content

Instantly share code, notes, and snippets.

@xanido
Last active May 10, 2021 11:34
Show Gist options
  • Save xanido/2a160880bf66fcd257a385f9cb118d12 to your computer and use it in GitHub Desktop.
Save xanido/2a160880bf66fcd257a385f9cb118d12 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# https://gist.github.com/xanido/2a160880bf66fcd257a385f9cb118d12
# what's happening?
# 1) first, curl the hover api searching for the first arg ($1)
# 2) pipe to `jq`, extract the results, discarding anything that isn't an exact keyword match and format as TSV
# 3) pipe TSV output of jq into a pretty table using `columns`. Use tab as the input delimiter
# 4) pipe the nice table to `sort` an sort by price, which when split by the separator ($) is the second key (2), (n)numeric sort, in (r)everse
curl \
--silent \
"https://www.hover.com/api/lookup?q=$1&exact_search=$1" \
| jq \
--raw-output \
'.results[] | select( .result_type == "keyword_match" ) | [.domain, .price] | @tsv' \
| column -t -s $'\t' \
| sort \
--field-separator "$" \
--key 2nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment