Get htop for Mac OS X to Watch & Manage System Resources
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 OS X. htop is basically a significantly improved version of top, which lets you monitor system resources, CPU core load, memory use, load averages, and manage running processes.
If you come 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 X
The easiest way to get htop running on 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 with Homebrew requires Homebrew as a prerequisite (obviously), this is easy:
- Open a web browser and go to the homebrew webpage http://brew.sh here
- 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:
- Once homebrew has successfully installed, you can install htop easily with the following command string:
- When htop completes installing, run ‘htop’ at the command line to enjoy htop in OS X
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install htop
And there you have it, htop runs in OS X!
Another option is to install htop through MacPorts as follows:
- Get MacPorts and install it if you don’t have it already
- After MacPorts is installed, launch a new Terminal window and type:
- Run ‘htop’ at the command line as usual on the Mac
sudo port install htop
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:
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 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.
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.
I had to install Xcode for MacPorts to work.
[…] 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 […]
I have always a htop open in my Visor Terminal (A Quake-style drop-down Terminal)
http://visor.binaryage.com/
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.
Does Homebrew have htop though? I thought it didn’t work?
It has htop, but I haven’t tried it.
$ brew info htop
htop HEAD
http://htop.sourceforge.net/
Not installed
For htop to display correctly all running processes, it needs to run as root.
If you don’t want to `sudo htop` every time, change the owner and permissions:
cd /usr/local/Cellar/htop/HEAD/bin
chmod 6555 htop
sudo chown root htop
http://github.com/mxcl/homebrew/commits/master/Library/Formula/htop.rb
I like homebrew better than MacPorts.
I like getting stabbed in the eye better than macports
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…
If you just installed MacPorts for the first time, you need to open a new shell for the command to work.
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)