A revised fix for the apropros long-entry problem

Mar 23, '07 07:30:00AM

Contributed by: ThaneQ

I'm frustrated and surprised that the problems with apropos have still not been fixed. I noticed this was discussed here before, but apparently those fixes don't work on my current install of Mac OS X 10.4.9. Using ideas from the prior hint, I added the following as a fix in my .bash_profile:

function aproposFunc() {
  width=`stty size | cut -d  -f2`; apropos $* | cut -c1-$width;
}
alias apropos=aproposFunc
Background:

For those not aware, the problem causes many lines (or pages) of extra information to be printed when you execute apropos key. The prior fix involved limiting the line-length as a pipe after the $PAGER variable (i.e. less), or using the -S command-line option. The current implementation of apropos no longer uses the $PAGER variable, but instead becomes a grep on a large text file at /usr/share/man/whatis. That text file is built by a system process, but perhaps ends up with the over-extended lines because of problems between makewhatis and the man pages' formatting.

[robg adds: This one didn't work for me in testing -- apropos serial returned the same long text as it did before ... if anyone can fix the code, please post in the comments. Note that I had to add single quotes around the alias entry in my .profile file to get the alias recognized.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070321234049584