Last active
January 17, 2018 00:01
-
-
Save donpdonp/ad9ef73fa78f409f1d59a832e32f860b to your computer and use it in GitHub Desktop.
coinmarketcap cli display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"DOGE", "ETH", "QTUM", "BTC" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL=https://api.coinmarketcap.com/v1/ticker/?limit=50 | |
FAV=`cat ~/.coinfavs` | |
JQ=' def pad(s; n): (n - (s|length)) * " "; | |
def lpad(s; n): pad(s; n) + s; | |
def rpad(s; n): s + pad(s;n); | |
map(select([.symbol] | inside(['"$FAV"']))) | |
| .[] | |
| [ ((2 - (.rank | length)) * "0") + .rank, | |
lpad(.symbol; 4), | |
rpad(.name;25), | |
"$" + rpad(.price_usd; 10), | |
lpad(.percent_change_24h; 6) + "%"] | |
| join (" ")' | |
curl --silent $URL | jq -r "$JQ" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment