Filesystem 1k-blocks Used Available Use% Mounted onWouldn't it be much nicer if you could have it output like this:
/dev/disk0s9 3121344 1314624 1806720 42% /osxfiles
Filesystem Size Used Avail Use% Mounted onRead the rest of this article if you'd like to learn how to create a more usable "df" (and other!) commands.
/dev/disk0s9 3.0G 1.3G 1.7G 42% /osxfiles
NOTE: I have packaged four of the more useful of these utilities (ls, dircolors (sets the colors for the new ls), df, and du) into one downloadable archive. These are pre-compiled, and you'll just need to expand the archive with OpenUp or the command line (or the new StuffIt Expander). Move the files into /usr/localbin, and they should be ready to go. I have NOT included the 'man' pages, since I wasn't sure how to do that - read the GNU online help for info on each command, or compile the whole package.
I'd seen references to a "human readable" version of 'df' in various places, but the command ('df -h') failed on OS X - the '-h' option is not known. So last night I went out to the GNU website, and took a look at their page of available software. One of the packages listed is 'fileutils,' which includes a number of file utilities, including versions of 'df', 'du', and 'ls' with the color option. GNU has a page that describes each program in the package, along with a full set of instructions in just about any format you might want. So I downloaded version 4.0 of the package (GNU's web site has a list of other mirrors) and set out to install it. This was my first-ever attempt at a compile and install under OS X, so I wasn't sure what was going to happen.
NOTE: The following instructions assume you have the developer's tools for the PB, which are available on Apple's Developer website (you have to register for a free online membership). I make no claim that the following steps are safe for your system; I am a complete novice at UNIX compilation, so I may have done some things incorrectly (please, osxhints UNIX experts, correct me if you see mistakes!). Use at your own risk...that said, my machine still seems stable and usable :-).
The basic installation was fairly straightforward. Download the package and expand it, and you'll wind up with a directory named fileutils-4.0. Here's what you do next.
- Start a terminal session, and become root ('su' and your root password).
cd /path/to/fileutils-4.0
./configure
This runs a script which attempts to set the proper variables for a proper compile on your system. It takes a while (five minutes?) to run.
- Compile the package by typing
make
- Install the programs and documentation by typing
make install
End your root session by typing 'exit'
In the tcsh shell path (you can view it by typing 'setenv'), the /usr/local/bin directory appears in front of the system-wide /bin directory. So the newly installed commands should work from any directory. Try df -h in some directory, and see if you get the sample output shown above. You can also try the color ls command, with ls --color.
In order to get the "man" pages working for these new commands, you need to modify the MANPATH variable. You can set this once, and it will remain in effect for future termina sessions. MANPATH tells 'man' where to look for manual pages. Type the following into your terminal:
setenv MANPATH /usr/local/man:/usr/share/man:$MANPATHThis inserts our new local man pages ahead of the existing path, so when you type 'man ls', you'll get the man pages for the new command instead of the old. To use any of the old commands, you'll need to put their path in front of them, like this: /bin/ls, /bin/df, etc.

