Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active January 30, 2016 22:00
Show Gist options
  • Save chmouel/8e4b2be7795e17e7b338 to your computer and use it in GitHub Desktop.
Save chmouel/8e4b2be7795e17e7b338 to your computer and use it in GitHub Desktop.
function mystock () {
local totalstock=NUMBEROFSTOCKYOUHAVE
local companystock=STOCKQUOTE
local yahoobase=http://download.finance.yahoo.com/d/quotes.csv?s
local yahooconv="${yahoobase}=USDEUR=X&f=l1"
local stockprice=$(curl -s "${yahoobase}=${companystock}&f=l1"|tr -d '^M')
local total=$[ $stockprice * $totalstock ]
local divided=$[ total / 4 ]
local eur=$(curl -s $yahooconv)
local eurtotal=$[ $total * $eur ]
local eurdivided=$[ $divided * $eur ]
printf "$fg[magenta]TOTAL$fg[default]: USD $fg[green]%d\$$fg[default]|EUR $fg[red]%d�~B�$fg[default] // DIV: USD $fg[green]%d\$$fg[default]|EUR $fg[red]%d�~B�$fg[default]\n" $total $eurtotal $divided $eurdivided
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment