Last active
January 8, 2016 19:15
-
-
Save velppa/a8af6d8a3702acc38c2f to your computer and use it in GitHub Desktop.
RBC stock index plugin for BitBar
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 | |
# File: rbc.15.m.sh | |
# Description: Plugin for BitBar (github.com/matryer/bitbar) displaying russian | |
# stock-market indicators from rbc.ru | |
# Author: github.com/schmooser | |
# Dependencies: | |
# jq - github.com/stedolan/jq | |
# pup - github.com/EricChiang/pup | |
# (install them using brew install jq pup) | |
# They should be added in PATH | |
export PATH=/usr/local/bin:~/Applications/go/bin:$PATH | |
json=$(curl -s -L http://rbc.ru | pup '.indicators__group json{}') | |
out="`echo $json | jq -r '.[] | .children | .[1:] | .[] as $c | "\($c.children | map(.text) | join(" ")) | color=\(if $c.children | .[0] | .text == "▲" then "green" else "red" end) | href=\($c.href)"'`" | |
echo "$out" | grep Brent | |
echo "---" | |
echo "$out" | grep -v Brent | grep -v EUR/USD | grep USD | sed 's/color=green/color=111/;s/color=red/color=green/;s/color=111/color=red/' | |
echo "$out" | grep -v Brent | grep -v EUR/USD | grep EUR | sed 's/color=green/color=111/;s/color=red/color=green/;s/color=111/color=red/' | |
echo "$out" | grep EUR/USD | |
echo "$out" | grep -v Brent | grep -v USD | grep -v EUR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of plugin usage