Last active
July 17, 2016 07:24
-
-
Save mariodian/2d1d261327a47837ad691f83daad8a98 to your computer and use it in GitHub Desktop.
The Bitcoin Script. Currently supporting ticker with various currencies.
This file contains 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
#!/bin/bash | |
if [ "$1" = "price" ]; then | |
currency=$([ "$2" = "" ] && echo "usd" || echo $2) | |
case $2 in | |
ltc) | |
pair="$2/usd" | |
;; | |
eur|*) | |
pair="btc/$currency" | |
;; | |
esac | |
echo "Fetching the current $pair price..." | |
case $2 in | |
eur) | |
price=$(wget -qO- https://www.bitstamp.net/api/v2/ticker/btceur/ | grep -E -o 'last": "[0-9.]+"' | grep -E -o '[0-9]+.[0-9]{2}') | |
price="$price EUR" | |
;; | |
ltc) | |
price=$(wget -qO- https://api.bitfinex.com/v1/pubticker/ltcusd | grep -E -o 'last_price":"[0-9.]+"' | grep -E -o '[0-9.]+') | |
price="\$$price" | |
;; | |
*) | |
price=$(wget -qO- https://api.bitfinex.com/v1/pubticker/btcusd | grep -E -o 'last_price":"[0-9.]+"' | grep -E -o '[0-9.]+') | |
price="\$$price" | |
;; | |
esac | |
if [[ $(which toilet) = "" ]]; then | |
echo $price | |
else | |
toilet -t -f bigascii12 $price | |
fi | |
else | |
echo "No argument provided." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment