Skip to content

Unix

View charts for stocks in the mop Terminal app

Yesterday, I noticed that the Stocks Dashboard widget in Mojave was no longer working. I couldn't find a similar (small window, always there, only stock prices) app that did what I wanted, but I did discover mop, a Go program that runs in Terminal. Using mop and Terminal's ability to save a window layout, I was able to craft a solution that worked for me.

Then commenter smayer97 asked…

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

I didn't pay much attention to the graphs in the widget, so I hadn't considered them in my solution. And there's no way I was going to find a tidy graphing solution that also worked in Terminal. What I came up with isn't quite as convenient as having the graphs available at all times, but it's pretty close—I just have to click on a ticker symbol while holding down some modifier keys:

As you might have guessed, this is powered by a Keyboard Maestro macro, and I love how well it works.

[continue reading…]



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.

[continue reading…]



How to upgrade a web host’s command-line PHP

The following is a very geeky, very niche1Where 'niche' is defined as 'of interest to maybe one person' tip, and I'm only documenting it here because it took me a while to figure it out, and I'd like to not have to go through that again if the need arises.

This site, and a few other personal projects, are hosted at Ionos, with whom I've been generally happy. On the web/GUI side, Ionos makes it really easy to control which version of PHP is used on your sites.

But I also have command line access to my server there, and I ran into an issue trying to run a PHP script (to upgrade another site). It threw an error, so I thought I'd check which version of PHP was in use…

$ which php
/usr/bin/php
$ /usr/bin/php --version
PHP 4.4.9 (cgi-fcgi) (built: Aug 29 2019 12:59:15)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

PHP 4.4.9 was discontinued in 2008—no wonder the script threw an error!

[continue reading…]



Living the bifurcated life in macOS Catalina

If you're a macOS Catalina user, and a user of Terminal for various tasks, you might be surprised at how some things work—or rather, don't work, in Catalina. As a first example, consider the Utilities folder…on the left is how it appears in Finder, and on the right, the contents of that same folder listed in Terminal:

While Finder shows a full Utilities folder, Terminal shows it as empty. Why? If you're somewhat familiar with the technical side of macOS Catalina, you probably know the answer: Apple has separated much of the OS and placed it on a read-only volume.

Apple's "About the read-only system volume in macOS Catalina" page explains things fairly well—basically, what you see as one Utilities folder in Finder is really two things: A read-only Utilities folder, and a user-writable Utilities folder. (If my machine had any user-installed apps in the Utilities folder, they would have shown up in the Terminal output above.)

[continue reading…]



See exactly when an app launched

Update: I guess I should have searched here before I posted this—I wrote up another solution a few years ago, and that one includes a Keyboard Maestro implementation. Whoops! As this one's another method, though, I'll leave it up.

I was working on some stuff for our upcoming Usher 2 release, and needed to know how long Usher had been running. A quick web search found this post, where one of the comments had an answer that works well in macOS:

ps -p pid -o lstart=

Replace pid with the process ID (PID) from ps -ax for the app or process in question, and you're done. But it's possible to make it even easier to use by automating the task of getting the process ID. Here's what I came up with:

ps -p `ps ax | grep [U]sher$ | cut -c 1-5` -o lstart=

The bit between the backticks gets the matching process line from ps, then uses cut to keep just the first five columns, which contain the PID.1When the shell encounters backticks, it processes the commands within those backticks before processing the rest of the command—in this case, the backticked command returns the PID.

[continue reading…]



Quickly create a nested folder structure via Terminal

Have you ever needed to create an empty folder structure with many levels of repetitively-named folders? This doesn't happen a lot, obviously, but if you try using Finder for this task, you'll quickly discover it's really tedious. But a quick trip to Terminal makes the task very fast, and it's not overly complicated.

Let's say you need a folder structure to handle reports that you'll be receiving weekly, but need to keep track of over both quarters and years. One way to handle that would be with a folder structure like this:

(Hopefully obviously, the same structure repeats within each separate year's folder.) Creating that many multi-leveled folders in Finder would be time consuming and tedious. But in Terminal, you can create the entire structure with just one command:

mkdir -p 202{0..5}/qtr{1..4}/week{1..13}

That command takes under a second on my iMac to create the entire directory structure (over 330 folders). Zoom! So how does this work?

[continue reading…]



Remove the macOS Catalina guilt trip from macOS Mojave

May 26 2020 Update: The 2020-003 Security Update for Mojave will reset the red flag (and deprecate the command used to ignore the update). However, these steps do still work, so you just have to repeat Miles' solution again. And after you do, do not open the Software Update panel, or the red badge will return. (But if it does, just run the commands yet again.)

May 9 2020 Update: Commenter Miles Wolbe has come up with a much better solution. Ignore everything in this tip, and just run this Terminal command:

sudo softwareupdate --ignore "macOS Catalina" && defaults delete com.apple.preferences.softwareupdate LatestMajorOSSeenByUserBundleIdentifier && softwareupdate --list

If you're interested in why this works, Miles explains it in more detail. I've tested this method, and it works—no more agent required!

I have no plans to move my main iMac to macOS Catalina, at least for the forseeable future. There are two key apps I use—Fujitsu's ScanSnap scanner software and the Many Tricks' accounting app—that are both 32-bit. In addition, there are changes in Catalina relative to permissions that make it somewhat Vista like and slow down my interaction with the system. (My MacBook Air is my "production" Catalina Mac, and I have an older retina MacBook Pro that I use for Catalina betas.)

But Apple really wants people to update to Catalina, so they let you know about Catalina…constantly, it seems. In System Preferences > Software Update, you'll see this…

[continue reading…]



Add inelegance to remove heat

At home, our network routing and firewall is handled by an open-source software package called pfSense®; it has a ton of features, and is relatively easy to configure. I built a mini PC (a box roughly 9" per side) for pfSense, and it's been running smoothly for over five years1I'll be writing more about pfSense and my routing PCs in a future post..

While it's not the world's loveliest box…ok, so it may be the world's ugliest box…

…it's been rock solid since day one. However, it's aging and its CPU won't be supported in an upcoming pfSense release, so I decided to replace it. (That way, I'll have a spare if the new one breaks…at least until that unsupported version of pfSense is released.) Here's the new box…

That's a Protectli fanless Firewall Appliance with a quad-core Celeron J3160 CPU, 4GB of RAM, and 32GB of storage. And yes, it's just a bit smaller and more elegant than my old box—the entire thing is roughly the size of my old box's external cooling fan.

[continue reading…]



How to auto-crop huge images with ImageMagick

In my recent post A new set of Hubble deep space iMac retina desktops, I included a set of auto-cropped 5120x2880 desktops. In that post, I wrote:

These images were automatically cropped from the master image (after I cropped that; more detail on what I did is coming in a follow-up post), via ImageMagick.

So this would be that post: How to auto-crop huge images using ImageMagick. If you're not familiar with it, ImageMagick is a set of command-line tools to manipulate images. There are a number of ways to install ImageMagick, but I used Homebrew (brew install imagemagick).

[continue reading…]



Easily see any app’s bundle identifier

I occasionally need to help one of our customers get the bundle identifier for a given app, for some purpose with one of our apps. While the task isn't complicated—the value is stored in a file named Info.plist within each app bundle—it's not something that's necessarily easy to explain to someone who doesn't have a lot of Mac experience.

I figured there must be a less-complicated solution, and I was right, though it's probably higher on the geek factor. After some searching, I found this thread at Super User, which offers a number of solutions. The simplest—and always working, in my experience—was the very first one: Open Terminal and run this command:

osascript -e 'id of app "Name of App"'

The "Name of App" is replaced with the name of the app as it appears when hovering over its Dock icon. For Excel, for example, it'd be:

osascript -e 'id of app "Microsoft Excel"'

Run that command, and it returns com.microsoft.Excel, which is just what I need—I just have the customer copy the output and email it back to me.