Skip to content

Commit

Permalink
Merge pull request matryer#1490 from makiftutuncu/exchange-rates
Browse files Browse the repository at this point in the history
Add exchange rates plugin
  • Loading branch information
matryer authored Dec 11, 2020
2 parents 14b69ed + 19f8d1d commit b7627ed
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Finance/exchange-rates.5m.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# <bitbar.title>Exchange Rates</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Mehmet Akif Tütüncü</bitbar.author>
# <bitbar.author.github>makiftutuncu</bitbar.author.github>
# <bitbar.image>https://github.com/makiftutuncu/exchange-bitbar/raw/master/Screenshot.png</bitbar.image>
# <bitbar.desc>This is a BitBar plugin for showing exchange rates of currencies in your menu bar. See https://github.com/makiftutuncu/exchange-bitbar#configuration for configuration.</bitbar.desc>
# <bitbar.dependencies>shell,curl,jq</bitbar.dependencies>
#
# Exchange Rates by Mehmet Akif Tütüncü
#
# This is a BitBar plugin for showing exchange rates of currencies in your menu bar.
# See https://github.com/makiftutuncu/exchange-bitbar#configuration for configuration.

export PATH="/usr/local/bin:$PATH"

# Currency pairs for which rates will show as array
CURRENCY_PAIRS=("USD-TRY" "EUR-TRY")

for pair in "${CURRENCY_PAIRS[@]}";
do
URL=$(echo $pair | awk -F '-' '{print "https://akifs-exchange-api.herokuapp.com/rates?source="$1"&target="$2}')
RESPONSE=$(curl -s -X GET $URL | jq -r '"\(.source),\(.target),\(.rate)"')
echo $RESPONSE | awk -F ',' '{printf "💵 %s-%s: %0.3f\n", $1, $2, $3}'
done

0 comments on commit b7627ed

Please sign in to comment.