See Share Quotes In Terminal / Geek Tool 4


See Share Quotes In Terminal / Geek Tool


This is a quick Terminal trick that I think is quite useful, especially if you are into stocks and shares and want to know the latest price of your portfolio. This tip is going to show you how you can pull a stock/share quote into Terminal. I’ll then go a bit further and show you how you can put the price in a form that is easily read for use in GeekTool or something similar.

To pull the price the trick is going to use a Terminal program called curl. Its used to download web pages off the Internet. To get the stock price we are going to use Yahoo Finance, they provide stock quotes in an easy format that can be read easily by Terminal, an added bonus is that it doesn’t need any formatting which makes our lives a bit easier.

To grab a share quote simply type or copy and paste the following into Terminal:

curl -s ''

Just replace “aapl” with the quote you are looking at. Yahoo Finance pulls quote from the NASDAQ, so stocks on other markets need to have the market identifier so a stock like HSBC is “hsba.l” within the URL. If you are stuck search for your quote within Yahoo and find the quote next to the name on the correct page.

The code, so far, just displays the stock quote. This at the moment isn’t that useful and in something like GeekTool you need a little bit more information. To do this we are just going to add the stock name to the quote.

echo Apple: $`curl -s ''`

When the code runs is should display something similar to the following:

Apple: $249.10

Just replace the name, currency symbol if needed and the quote and you can customise it to everything you need. Simple.

If you have any questions or comments, please leave one below.

If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips