Skip to content

Go old school Terminal for stock quotes

My main machine is still running Mojave, and will be for some time—our accounting app and my scanner both rely on 32-bit code. For a very long time, I've been using the built-in Stocks widget from the Dashboard (something else that's gone in 10.15) to track stocks I own or am interested in following.

I have two displays, so I just dedicate a small corner on one of them for the Dashboard widget, which I detach from the Dashboard using an old but still functional Dashboard devmode hint. The Stocks Dashboard widget is quite narrow, and not all that tall, so it didn't take a lot of space.

But recently, it broke, as you can see in the image at right. I set out looking for a replacement—just a simple desktop app that would open a window with stock quotes. Apple's own Stocks app doesn't meet my needs—it has a huge News area you can't close. Similarly, the Stocks section of the Today area in Notification Center requires mouse movement and action on my part to see.

I took a look at any number of third-party apps, but all of them were either full-blown stock traders/managers, lived in the menu bar or Dock, or were discontinued. I finally found what I was looking for, not in a desktop application, but in mop—an open source Go program—running in Terminal.

After a bit of setup work, here's what I'm now seeing1While I wish I had bought a lot of these years ago, I didn't—these are just some sample stocks on my desktop:

Yes, the window is slightly wider than my old one2It's actually incredibly wide, but I don't need to see the other columns, but it's not as tall, and I was able to find a spot for it. If you'd like to try mop yourself, setup is relatively simple.

Because mop is written in Go, you'll need to have the Go language installed. I did so using Homebrew (brew install go), though I imagine it's also available via MacPorts and Fink. You can also download a binary version directly from the Go site, though I'm not sure what would then be required to integrate it into the command line side of macOS.

After installing Go, I proceeded to the mop site to follow their instructions, which appear pretty simple:

# Make sure your $GOPATH is set.
$ go get github.com/mop-tracker/mop/cmd/mop
$ cd $GOPATH/src/github.com/mop-tracker/mop
$ make            # <-- Compile and run mop.
$ make build      # <-- Build mop in current directory.
$ make install    # <-- Build mop and install it in $GOPATH/bin.

The only issue I ran into was the very first comment, about making sure the $GOPATH was set. When I checked (echo $GOPATH), mine was blank. I did a bit of searching, and the $GOPATH variable is used to basically tell Go where to put stuff. I created a new folder named gostuff, and then ran this command to set $GOPATH to point at it:

export GOPATH="/Users/myuser/path/to/gostuff"

Once that was done, the next two commands grab the files from the repository and then change into the folder that contains the mop source:

$ go get github.com/mop-tracker/mop/cmd/mop
$ cd $GOPATH/src/github.com/mop-tracker/mop

You can then choose how to build and install the app; I used make build, which created a binary file in the current directoy. I then moved that binary to the folder where I keep my other user-provided binaries, and deleted all the source files.

All that was left was to customize the stocks, and set up a Terminal window for mop. You'll find the configuration file, .moprc, in your user's home folder, and it's pretty clear how to edit it.

To set up a Terminal window, I duplicated an existing profile and renamed it to Stocks. The modified profile uses a different font and size, has a custom fixed title (Stock Quotes), and has a few other changes from my normal profile. The one key change is in the Shell tab, where I specify that the mop command should be run on startup:

I then opened a new Terminal window, applied the customized profile, and sized and positioned the window as I wanted it. The last step was to use Terminal's Windows → Save Windows as Group command to save the layout.

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.

When the market's closed, it's really easy to close the window so it's not just sitting there—while it was easy to remove the Dashboard widget, it took a bit more work to get it back.

I'll give this solution a try this week, but so far, I like it. I have Terminal running all the time anyway, so I might as well put it to more use.

8 thoughts on “Go old school Terminal for stock quotes”

  1. The Makefile in the mop project turns out to do basically nothing. It’s just a wrapper around a one line command. If someone wants to install the project and doesn’t have a copy of the binary, this should be sufficient:

    Install Go.
    Run:

    GOBIN=$(pwd) GOPATH=$(mktmp -d) go get github.com/mop-tracker/mop/...

    The binary will be placed in the current directory.

  2. Nice project...

    Any solution to replace the mini-graphs at the bottom of the old Dashboard widget?

    1. That'd be a lot tricker to pull off in a small Terminal window :). Someone did point me to this Unix app, which has ASCII art graphs:

      https://gitlab.com/aenegri/toro

      I haven't installed it :). However, you've given me a thought on a way to get graphs, albeit not directly in my little Terminal window. Look for a new post tomorrow :).

      -rob.

      1. Nice. But do consider any other options, if they exist, not just terminal based ones.

        1. You mean for the charts? Yea, not Terminal based, because I think it'd be impossible to replicate what's shown in the widget. And my solution doesn't try to replicate that, but just makes it about as simple as possible to get a chart for given stock in the list.

          -rob.

Comments are closed.