How to enable ccache with OS X MacPorts

I’ve had a 13″ Macbook for about your years now. When I learned about MacPorts I was really happy to know I could run newer software, and compile things to my liking. These days I run a development environment on my Macbook, all built using MacPorts.

This post covers how to leverage ccache in compiling your MacPorts. ccache is a compiler cache utility that increases the efficiency of your compiles by reusing cached build data, often improving build times by 5-10 times!

Step 1: Install ccache

sudo port install ccache

Step2: Edit macports.conf”

Open /opt/local/etc/macports/macports.conf in your favorite editor. Find the line ‘configureccache’ (near line 65)

configureccache no

and change it to

configureccache yes

You’re done! New compiles will now use ccache.

note: ccache stores it’s cached date in your home directory, ie; /Users/$username/.ccache. It defaults to a maximum cache storage size of 1G. You can find out more about the ccache settings via the ‘ccache -s’ command.

Fix Home and End Keys: Mac OS X

One of the things that has long bugged me about Mac OS X (one of the few things!) is the different way that the Home and End keys function inside a document. I have long been used to Home moving to the beginning of the current line, and End moving to the end of the current line (both on Windows and Linux machines), but on OS X they seem to move to the end of the document and the beginning of the document. After months of working on OS X I have yet to get used to this functionality so today I set out to find a solution. This is what I found.

I quickly found that there are a lot of people with this same gripe. Google is ripe with suggestions. Some of them manual keyboard re-mapping tricks, others suggesting the “Mac way” to achieve the same, and some with third-party software solutions. I went with the latter in this case.

There is a free program available called DoubleCommand, which allows you to remap the way your keyboard works with a number of pre-defined checkboxes. All you need to do in order to gain the “normal” Home and End functionality is to click a box and Activate the changes. Here are five steps you can follow to achieve Home and End normalfication.

  1. Download DoubleCommand
  2. Install by double-clicking on the .pkg file and following the prompts.
  3. Launch DoubleCommand via: Apple > System Preferences > DoubleCommand
  4. Select “PC style Home and End keys”
  5. Save (System wide or User) and Activate

Next time you’re in a document and need to hit the beginning or end of a line, simply press fn-home/end and you’ve got the functionality the way you might expect it to work. Enjoy!

If you have any other solutions to this problem please share them in the comments. As they say, there is more than one way to skin a cat!

Quickly Lock Your Screen: Mac OS X

I’ve been using my Mac more and more while I’m at work these days and one of the things that I quickly started to miss was the Linux keyboard shortcut for locking your screen (ctrl-alt-l) when you’re going to be away from your desk. The first few times I simply resigned myself to trust my office mate, but that wasn’t going to cut it long-term. I set out to find a solution to locking my screen while I was going to be away from my Mac. This is what I found.

There are actually a number of solutions that I found. Some require third-party software. Others require creating dock icons to launch command-line tools. The solution I came up with requires no third-party software, custom dock icons or arthritis-inducing keyboard shortcuts. This uses easily configurable options that can also easily be undone if desired. I used Hot Corners.

If you’re not familiar with Hot Corners, it is the ability to use your mouse and the four corners of your desktop to achieve additional functionality. I use my upper-right hand corner to launch Spaces. The lower-right for Expose (All Windows). I’ve now added the lower-left to launch my Screensaver. By configuring my machine to activate the screensaver when the mouse is in the lower-left corner of the screen I am easily able to lock my screen when I need to be away from the computer. I simply drag the mouse down, screensaver turns on (which requires a password to unlock, of course) and I’m golden.

To activate this feature, do the following:

  1. Click Apple > System Preferences > Desktop and Screensaver
  2. In the lower left corner of that window you’ll find a button that says “Hot Corners”. Select that and then select one of the four corners to “Start Screensaver”.

As I mentioned before, there are other solutions to this problem, but this is the solution that I found the least complicated or difficult to setup. Do you have another solution that you consider easier? Let us know in the comments.

Remove Unneeded Languages in Mac OS X

I ran into this little tip today on Command-Line-Fu.  It automagically finds and deletes all non-english language sets installed on your machine.  This is, of course, a Mac OS X tip so you wont get very far running it on your Linux machine.  I have two OS X desktops at home so I found it applicable.  I know there are quite a few of you closet OS X users out there as well.  We’ll just let this one be our little secret.

sudo find / -iname "*.lproj" -and ! -iname "en*" -print0 | tee /dev/stderr | xargs -0 rm -rfv

Can anyone suggest making this command any more efficient?  Just looking at it (without testing) I may have tried something like this:

sudo find / -iname "*.lproj" -and ! -iname "en*" -exec rm -rf {} \;

note: replace the “en*” with the language you want to keep if other than english.  Also replace -exec with -ok if you want to manually OK the deletion of any/all files found.