So then I went to the Terminal and spent a bit of time looking at top's options. top will let you run a given number of samples with the -l option, and if you specify 0 as the sample count, you'll get an infinite number of samples. Combine this with grep to isolate the Finder from top's output, and you get the following command and output, updated every second.
robg$ top -l 0 | grep Finder
406 Finder 0.0% 0:19.09 1 134 209 7.45M 37.4M 25.0M 267M
406 Finder 0.8% 0:19.10 2 139 212 7.46M+ 38.9M+ 25.1M+ 268M+
406 Finder 7.2% 0:19.19 2 145 212 7.48M+ 38.9M+ 25.2M+ 268M+
406 Finder 9.2% 0:19.30 2 142 213 7.48M 39.6M+ 25.7M+ 269M+
406 Finder 6.6% 0:19.38 2 142 211 7.47M- 39.0M- 25.2M- 268M-
^C
So there's one relatively trivial solution -- I then resized the Terminal window to a very small size, and just let that scroll by for a while as I worked.
I still wasn't quite happy, though, as this still took up a fair bit of screen real estate, and I had to be sure to make a new Terminal window when I wanted to use Terminal itself. The image at left is more like what I was after ... read the rest of the hint to see how it was created after some detective work by myself and Kirk McElhearn...I thought that GeekTool (a previous Pick of the Week selection) might be a perfect answer to this problem, as it can output Terminal commands to floating desktop windows. Ideally, I'd just be able to tell GeekTool to run top -l 1 | grep 'Finder', set that to auto-update every second, and be done with. Unforunately, top -l 1 will always return a 0.0% utilization on the one sample it runs; it's only the second and subsequent samples that return the actual utilization. So I needed a way to ignore the first reply, and focus only on the second.
There were some other issues as well. I didn't want nor need the extraneous memory usage information; I was just interested in CPU usage. And the top command by itself is very CPU intensive, so you'll be loading your CPU if you run the command every second or two. So Kirk and I spent a bit of time this morning trying to put this all together to come up with the ultimate one-line GeekTool single-process monitoring tool. After some trial and error, here's what we wound up with to generate the image you saw above:
top -FR -l2 | grep Finder | grep -v 0.0% | cut -c 7-25
Here's how each piece works:
- top: Launch the top command, which shows all running processes and a bunch of information about each one.
- -FR: The F option tells top not to calculate stats on frameworks; the R option tells top not to report on the 'memory object map' for each process. The net of both of these options is that top consumes much less CPU than it does in its normal mode.
- -l 2: Run two samples in top. The first will always return 0.0%, so we need two.
- | grep Finder: Only show output containing the word Finder.
- | grep -v 0.0%: Skip any rows containing 0.0%. This effectively skips row number one (and yes, any time the Finder is at 0.0% actual usage, you'll get a blank display in GeekTool).
- | cut -c 7-25: This shows only columns 7 through 25 of the output, which are those containing the word Finder and the utilization number.

