27
votes

The top command on OS X is pretty crappy.. The one included with most Linux distros allows you to change the sort-by column using < and >, there is a coloured mode (by pressing the z key), and a bunch of other useful options.

Is there a replacement command line tool? Ideally I would like htop for OS X, but because it relies on the /proc/ filesystem (see this thread) it has not been ported (and probably will never be)

The obvious answer is "Activity Monitor", but I'm looking for a command line tool!

4
  • 3
    <3 htop. +1 added for this reason. Message extended because of the stupid character requirement. May 2, 2009 at 13:52
  • ok, I've answered the 'sort' problem - what other "useful options" are you missing?
    – Alnitak
    May 2, 2009 at 16:37
  • 3
    Note that a /proc filesystem can be made available using MacFUSE: osxbook.com/book/bonus/chapter11/procfs I don't know of any 'top' port that leverages this, however. May 3, 2009 at 18:54
  • 1
    I'm afraid that the MacFUSE procfs is not a drop-in replacement for Linux's procfs. When I tried compiling htop (or running dstat), I was stopped because there is no /proc/stat directory. Jun 2, 2009 at 20:15

6 Answers 6

23
votes

top on MacOS X does support sorting, at least:

    O<skey>        Set secondary sort key to <skey> (see o<key>).
    o<key>         Set primary sort key to <key>: [+-]{command|cpu|pid
                   |prt|reg|rprvt|rshrd|rsize|th|time|uid|username|vprvt
                   |vsize}.
20
votes

I'm working on porting htop to OSX. The repo is here (more active fork here, and can be installed via brew install htop)

I'm currently trying to work out what to do about the licensing clash between Apple's libtop (APSL) and htop (GPL). There's probably not much more programming to do on it - but I may have to re-implement the bits of libtop I need. If anyone has suggestions on how to make the licensing work please speak up.

enter image description here

3
  • Screenshot: flickr.com/photos/andyarmstrong/3651319080
    – hexten
    Jul 2, 2009 at 10:26
  • 1
    Good work, my only concern is that you need to run it with sudo to see memory information. If posible make it work without asking for sudo, try to escalate directly from it.
    – sorin
    Dec 8, 2012 at 15:50
  • Unfortunately mouse clicks do not work.
    – Erik Kaju
    Nov 5, 2014 at 12:40
9
votes

htop is now part of macports -- enjoy

8
votes

Glances - Eye on your system is what you are looking for. I previously used it on Linux, it is cross-platform and is really good.

Here is my screenshot.

enter image description here

7
votes

There is also a brew for htop if that's how you roll.

Unfortunately, Apple's /usr/bin/top continues to regress, as it no longer even understands compound single char args:

$ top -FR
invalid option or syntax: -FR
[...]

Now you must use e.g. "top -F -R -u". But, hey, Apple's "top" does not sort by cpu by default so perhaps that's the least of its worries.

3
votes

Top on OS X requires a little tweaking (it's not as 'blinged out' as GNU top), but it's easy to do.

On Leopard or Tiger, I use 'top -FRo [field]', where '[field]' is typically cpu, vsize, rsize, and so on. The -F and -R options will sacrifice some precision for memory calculation for a huge decrease in CPU usage by top.

Not the answer you're looking for? Browse other questions tagged .