| Article Index |
|---|
| How to configure common CLI tools on Mac OS X |
| Get the configuration files, and get started |
| Configure the Shell |
| All Pages |

Even if you configured properly the application Terminal on your Mac, you may think using it is difficult, and not intuitive at all. Indeed, with the default configuration for the common command line tools, you won't get syntax highlighting within vim, nor will you have a shell which facilitates your work, and so on. But since I started my journey in Mac universe after spending some time on Linux, I am used to configure some of these tools, and I simply decided to make my shell and my other CLI tools on my mac look like what I previously had in my Linux box.
So, let me tell what I did to have really usable command line tools on my Mac...
For your information, I did all these things on Mac OS X Leopard 10.5.6. Let's get started!Install MacPorts
First of all, I noticed some of the tools I liked were missing on my Mac. Basically, every command line tool can be difficult to find, and at the same time, you may want to use a package management system to manage such software. So I could choose between MacPorts, and Fink. Although Fink seemed more powerful (in fact, more Debian like), I had the impression it wasn't very active at the time I wanted to install it. So I chose MacPorts.
MacPorts is rather handy in fact, since it will automatically fetch the sources of what you want to install, and compile it with the right options. It's not perfect, and I already experienced some compilation failures with it, but it works most of the times, and it's rather straightforward. One of the things I regret when I remember Debian's aptitude, though, is its advanced dependency management system; indeed, I think MacPorts' one is more basic. But hey, nothing is perfect.
Basically, I just installed MacPorts using the Leopard (Universal) “dmg” disk image, but you must install some other things first. Just refer to the download page of MacPorts. I also encourage you to read the MacPorts Guide, which explains with more details how to install MacPorts properly and how to use it. But you can just skip the part called “MacPorts and the Shell”, and instead do the following in a Terminal window:
% sudo sh -c 'echo "/opt/local/bin\n/opt/local/sbin" > /etc/paths.d/macports'
% sudo sh -c 'echo "/opt/local/share/man" > /etc/manpaths.d/macports'
Let's continue...
Install some tools with MacPorts
Once MacPorts is installed, you can easily install some useful tools. For the rest of this tutorial, you will just need to do the following:
% sudo port install figlet fortune par wget
The tools figlet and fortune are some fun tools, you will see later why we need them; par is very useful to wrap lines with vim, and wget can be used to fetch some files from the internet without using curl.
But for your information, here is the list of the other tools I usually install:
- convmv: to re-encode some filenames;
- nmap: to discover open ports on remote servers;
- irssi: an excellent text based IRC client;
- p7zip, pbzip2, unrar: compression utilities;
- potrace: to vectorize bitmap image files;
- pstree: to see in a fancy way the list of processes running on your Mac;
- signing-party: to help you sign some GnuPG keys;
- w3m: a text based web browser.
% sudo port install mutt-devel +gdbm +headercache +imap +pop +ssl
It will install the right version of mutt with the right variants to enable everything which can be useful.
That's it for MacPorts!






For my concern, the /opt folder wasn’t there before MacPorts install (I don’t know if it’s the only one to use it?).
In order to "clean" the all thing, I found two interesting issues:
1- I don’t like to see the whole content of /Developer and /opt in the Spotlight search. So I first recommend to get these two in the excluding list of Spotlight (System Preferences).
2- I looked a little bit to know how to hide /opt like /usr, /etc are.
In an OS X way, it’s not that bad! :-). Obviously, putting a . in front of the name is no solution... At all.
You’ll need the Developer Tools, but you are supposed to install them anyway if you want to use MacPorts.
In the Terminal.app of course, use the brand ‘new’ root user:
root@machine ~# SetFile -a V /opt
Basically, it’s switching a bit in the file, responsible for (in)visibility in the Finder. Usually, you have to reload the Finder, but I didn’t have to.
It’s nicer :-)