Back in 2020, I explained how to use Terminal to display stock quotes. Once set up, it looks something like the image at right, though that's a four-year old screenshot, so the prices are way off!
In a follow-up post, I showed how to quickly chart any of the stocks in your list. I've moved to a new Mac since then, which means (as always for me with a new Mac), I set it up from scratch.
Sometimes not everything makes the cut for the new Mac; in this case, my Terminal quotes were one of the things that didn't make the cut.
But I recently decided I wanted them back, and the good news is that it's gotten a bit simpler in four years since I last wrote about this. And I took the time to improve the stock charting macro, too.
Read on if you're interested in geeky Terminal stock quotes…
Initial setup
mop still requires Go to be installed, which can be done in any number of ways—I used Homebrew. After that, installing mop has gotten a bit easier. You still need to have $GOPATH defined; I used a folder named gostuff, and then set the value with the export command:
export GOPATH="/Users/myuser/path/to/gostuff"
Once that's done, make a new folder or cd
into one where you can download some stuff, and run the mop setup commands, as seen on their site:
$ git clone https://github.com/mop-tracker/mop $ cd mop $ go build ./cmd/mop $ ./mop
The last line launches mop, so you may not want to do that yet. Instead, move mop to wherever you keep your Terminal programs. Once that's done, then you can test mop and make sure it works. To customize the stocks, you can just hit "+" and "-" in mop, or edit the .moprc file in your user's Home folder. In theory, you're now done…but you probably want a customized Terminal window for mop.
Customize the Terminal window
To set up a customized Terminal window, I duplicated an existing profile (Settings > Profiles) and renamed it to Stocks. My modified profile uses a different font and size, and has a custom fixed title (Stock Quotes). Note: If you're going to use the Keyboard Maestro macro for stock charting, you must create a custom title for your stock window that's not shared with any other Terminal windows.
One key change is in the Shell tab, where I specify that the mop command should be run on startup:
One other key change—and the one that took me the most time to figure out when I set this up again—relates to customizing the colors that mop uses to display stocks that are up, down, or unchanged. I don't like the default colors, but because mop only uses the 16 standard ANSI colors, the choices are limited for replacement values.
But Terminal allows you to redefine the 16 standard ANSI colors in the Text tab of any defined Profile, using the Text tab of that profile's settings panel:
Click on any color, and you can replace it with any other color, picking from millions of choices. You still only have 16 to work with, but each of those 16 have millions of possibilities.
For example, the selected color in the above screenshot can be described in a number of ways, but "red" isn't one of them. But because my profile now has this defined as red, it's what's displayed whenever mop calls for red output. So while the program doesn't directly support any color, you can define any of 16 holding spots as any color you wish, and then just reference that color name in the .moprc file.
Once I had the profile all set up, I opened a new Terminal window, applied the customized profile, and sized and positioned the window where I wanted it to go. The last step was to use Terminal's Window → Save Windows as Group command to memorize the size, location, and profile for my custom stocks Terminal window.
Once saved, activation is as simple as one menu command…
…or even a keyboard shortcut, as seen in the screenshot, making it even easier to activate.
The charting macro
The charting macro now lets you chart a stock with either a defined preferred provider, or by choosing a provider from a pop-up list when the macro runs—you can use either method each time you invoke the macro.
There are two variables whose values you must check or set for the macro to work; both are located near the top of the macro, in green-colored boxes.
The first is the local_windowTitle variable. Set this to the custom title you gave your Terminal window when you customized it for mop. This is important, as the macro checks the window title before it does much of anything else.
The second variable, local_preferChart, defines the default charting provider you'd like to use; you can see it, and the list of choices, in the yellow box near the top of the macro:
Enter one of the words from the top box in the green box below; this is the provider that will be used by default—but you'll be able to choose from the others during any use of the macro.
The macro no longer triggers on mouse clicks and modifiers, as I found that too complicated. Instead, place your mouse directly over the ticker symbol you want to chart (in the leftmost column of mop), then hit Control-G. This will open the chart for the stock under the mouse using the chart provider you specified in the green box.
If you'd like to pick from a list of providers when you run the macro, after positioning your mouse, launch the macro with Shift-Control-G; this will pop-up a selector box:
Choose the desired chart provider, and for this one run, the chart will open on that provider's page.
Here's the macro; feel free to change the hot keys, but if you do, make sure the "optional charts" version includes the Shift key, as that's what the macro looks for to trigger the pop-up selector.