Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
733 B

9 months ago
9 months ago
  1. # price=$(curl -s "https://api.kraken.com/0/public/Ticker?pair=$1" | jq -r ".result.$1.b[0]")
  2. raw=$(curl -s "https://api.kraken.com/0/public/Ticker?pair=$1")
  3. # echo $raw
  4. if [ "$1" = "BTCUSDC" ]; then
  5. price=$(echo "$raw" | jq -r ".result.XBTUSDC.b[0]")
  6. else
  7. price=$(echo "$raw" | jq -r ".result.$1.b[0]")
  8. fi
  9. # echo "$price"
  10. if (( $(echo "$price < 1" | bc -l) )); then
  11. printf "%0.3f\n" "$price" | cut -c 3-
  12. elif (( $(echo "$price < 10" | bc -l) )); then
  13. printf "%0.3f\n" "$price" | cut -c 3-
  14. elif (( $(echo "$price < 1000" | bc -l) )); then
  15. printf "%'0.1f\n" "$price" | sed 's/,//'
  16. elif (( $(echo "$price < 10000" | bc -l) )); then
  17. printf "%'0.0f\n" "$price" | sed 's/,//'
  18. else
  19. echo "$price" | cut -c -3
  20. fi