mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
first commit
This commit is contained in:
parent
e273cf004e
commit
da9c3f2b2b
2 changed files with 55 additions and 0 deletions
19
plugins/coinmarketcap/README.md
Normal file
19
plugins/coinmarketcap/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Unofficial Cryptocurrency Market Capitalizations coinmarketcap.com
|
||||||
|
|
||||||
|
[coinmarketcap](https://coinmarketcap.com) plugin — Market Capitalization is one way to rank the relative size of a cryptocurrency. It's calculated by multiplying the Price by the Circulating Supply.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For Bitcoin Gold
|
||||||
|
```
|
||||||
|
coin BTG
|
||||||
|
```
|
||||||
|
|
||||||
|
For all currencies
|
||||||
|
```
|
||||||
|
coin ALL
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
commands like awk, grep and curl need to be in the $PATH
|
||||||
|
Tested in Linux and MacOs
|
||||||
36
plugins/coinmarketcap/coinmarketcap.plugin.zsh
Normal file
36
plugins/coinmarketcap/coinmarketcap.plugin.zsh
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
# Displays the current USD value of crypto coins from the api.coinmarketcap.com
|
||||||
|
#
|
||||||
|
# See README.md for details
|
||||||
|
|
||||||
|
function coinmarketcap() {
|
||||||
|
curl -s https://api.coinmarketcap.com/v1/ticker/ > $HOME/.coinmarketcap.json
|
||||||
|
curl -s https://api.coinmarketcap.com/v1/ticker/bitcoin-gold/ > $HOME/.coinmarketcap-btg.json
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
coin=$1
|
||||||
|
symbols=(`cat $HOME/.coinmarketcap.json | grep -Po '(?<="symbol": ")[^"]*' | awk -F "\n" '{print $1}'`)
|
||||||
|
price=(`cat $HOME/.coinmarketcap.json | grep -Po '(?<="price_usd": ")[^"]*' | awk -F "\n" '{print $1}'`)
|
||||||
|
if [[ "${coin}" == "ALL" ]]; then
|
||||||
|
for ((i=0; i<${#symbols[*]}; i++));
|
||||||
|
do
|
||||||
|
echo -e ${symbols[i]}"\t : \t"${price[i]}
|
||||||
|
done
|
||||||
|
elif [[ "${coin}" == "BTG" ]]; then
|
||||||
|
btg_symbols=(`cat $HOME/.coinmarketcap-btg.json | grep -Po '(?<="symbol": ")[^"]*'`)
|
||||||
|
btg_price=(`cat $HOME/.coinmarketcap-btg.json | grep -Po '(?<="price_usd": ")[^"]*'`)
|
||||||
|
echo -e ${btg_price}
|
||||||
|
else
|
||||||
|
for ((i=0; i<${#symbols[*]}; i++));
|
||||||
|
do
|
||||||
|
if [[ "${symbols[i]}" == "${coin}" ]]; then
|
||||||
|
echo -e ${price[i]}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Usage example for Bitcoin Gold: \"coin BTG\""
|
||||||
|
echo "Usage example all crypto currencies: \"coin ALL\""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
alias coin=coinmarketcap
|
||||||
Loading…
Add table
Add a link
Reference in a new issue