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.