Skip to content

Instantly share code, notes, and snippets.

@velppa
Last active January 8, 2016 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velppa/a8af6d8a3702acc38c2f to your computer and use it in GitHub Desktop.
Save velppa/a8af6d8a3702acc38c2f to your computer and use it in GitHub Desktop.
RBC stock index plugin for BitBar
#!/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
@velppa
Copy link
Author

velppa commented Jan 8, 2016

Example of plugin usage
screen shot 2016-01-08 at 18 48 00

@velppa
Copy link
Author

velppa commented Jan 8, 2016

Updated accordingly common-sense colors regarding USD/EUR rates - if they raise it's RED color, not GREEN.

screen shot 2016-01-08 at 19 16 55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment