Get htop for Mac to Watch & Manage System Resources, CPU, Memory, etc

May 6, 2011 - 12 Comments

htop for Mac OS X

If you like to keep an eye on system resources and you want to branch out from the GUI Activity Monitor, check out htop for Mac. htop is basically a significantly improved version of top, which lets you monitor system resources, CPU core load, memory use, load averages, and view and manage individual running processes.

If you’re coming to Mac from the linux world, you’re probably already familiar with htop, but if you’re not here’s why it’s better than top: for starters, it just looks better and is easier to read thanks to an improved layout and use of ANSII colors, but beyond that it’s great because it functions much like a task manager, allowing you select and then renice or kill processes as needed. I find this easier than manually entering PID’s through top. Anyway, let’s get htop installed in Mac OS X via a package manager like Homebrew or MacPorts.

How to Install htop in Mac OS

The easiest way to get htop running on MacOS or Mac OS X is by installing it through MacPorts or Homebrew, which package manager you use doesn’t matter but you’ll only want to install it in one so you don’t overlap and double-install. We’ll cover installing htop with Homebrew first, and MacPorts second.

Installing htop on Mac with Homebrew

To install htop via Homebrew obviously requires Homebrew as a prerequisite, so that’s part of the installation process covered here. If you already have homebrew installed on the Mac, skip that portion:

  1. Open a web browser and go to the homebrew webpage http://brew.sh here
  2. Copy and paste the install command string into the terminal, it usually looks something like the following – GET THE EXACT COMMAND from brew.sh as it sometimes changes the script reference, do not just copy and paste:
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  4. Once homebrew has successfully installed, you can install htop easily with the following command string:
  5. brew install htop

  6. When htop completes installing, run ‘htop’ at the command line to enjoy htop in Mac OS

And there you have it, you now have htop running on the Mac.

htop for Mac OS X running in Terminal

Homebrew is arguably the most popular command line package manager for Mac, so for most Mac users you’ll likely go with Homebrew.

Installing htop on Mac with MacPorts

Another option is to install htop through MacPorts, which if you already have Homebrew this is a bit redundant, but if you already have MacPorts or prefer MacPorts for some reason, here’s how to use this:

  1. Get MacPorts and install it if you don’t have it already
  2. After MacPorts is installed, launch a new Terminal window and type:
  3. sudo port install htop

  4. Run ‘htop’ at the command line as usual on the Mac

Installing htop may take a while because it requires quite a few dependencies (zlib, openssl, perl, etc), but Homebrew and MacPorts will handle installing and downloading them all for you. If you have none of this already on your Mac, it could take up to 15 minutes for all of the necessary files to download, compile, and install.

After Homebrew or MacPorts is complete, launch a new Terminal session and type ‘htop’ to access the app. You navigate and use htop through the arrow and function keys, which you’ll see are laid out at the bottom.

I find htop to look best at fullscreen against a white background, but if you have a slightly transparent black terminal it looks great too:

htop for Mac OS X

Finally, it’s worth pointing out you can also build htop from source, if you’re into that sort of thing. You will likely need a few dependencies in MacOS / Mac OS X, however, but the source for htop can be found here at the Github page for htop.

If you like this, be sure to check out more command line tips.

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks

12 Comments

» Comments RSS Feed

  1. acet3chnician says:

    Also works well if you run htop as an alias for top. That way top always brings up htop, at least in oh-my-zsh.

  2. charleshb says:

    I had to install Xcode for MacPorts to work.

  3. […] you could just install htop for Mac OS X through MacPorts or Homebrew. htop is superior to top in many ways, but because it requires […]

  4. I have always a htop open in my Visor Terminal (A Quake-style drop-down Terminal)

    http://visor.binaryage.com/

  5. Dave says:

    Nice to hear about htop! Not so nice to hear the suggestion that one should install it via Mac Ports. Frankly Mac Ports sucks, you will end up with tons of dependencies installed that do nothing for you.

    Not to complain but a tool like this really needs to be 100% Mac native and only dependent upon installed software. That is the base Mac OS/X system. So while htop is a cool idea, having to install tons of crap isn’t.

  6. Ian says:

    Does Homebrew have htop though? I thought it didn’t work?

  7. roy_hu says:

    I like homebrew better than MacPorts.

  8. nobrainer says:

    I get port htop not found…

    when I went to sourceforge i checked out the svn but can’t run it. macports did load however…

    • Will says:

      If you just installed MacPorts for the first time, you need to open a new shell for the command to work.

      • nobrainer says:

        I tried that, still no go.
        Could it be because I’m using Xcode 4.x on 10.6 server? (trying to track down a memory leak)

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site