home > mac > lsregister.html

Wednesday, October 17th, 2007

Clean up your Contextual Menus

Thanks to this TidBITS article, I was tipped off to find this Mac OS X Hint about how you can rebuild the Launch Services database that determines which applications show up in your “Open With” contextual menu. My Open With had a huge amount of cruft accumulated over time with Classic apps, apps on my backup hard drive, and an annoying number of image droplets in the Photoshop/Samples/Droplets folder.

So I rebuilt my Launch Services database to make my Open With much cleaner and faster. Here’s how I did it.

  1. Eject my backup hard drive so that the database doesn’t include duplicate copies of all my applications.

  2. Archive the Photoshop/Samples/Droplets/ folder (right click, Create Archive, then delete the folder).

  3. Add the following line to my ~\.profile so typing the lsregister command is easier. (alias ... should all be on one line)

    # make launch services register easy to find
    alias lsregister='/System/Library/Frameworks/
        ApplicationServices.framework/Frameworks/
        LaunchServices.framework/Support/lsregister'
    
  4. Save a description of the old database (out of curiosity, not necessary).

    lsregister -dump | less > lsregDumpOld.txt
    
  5. Rebuild the database. (all on one line)

    lsregister -kill -r -f -domain system -domain system
        -domain user "/Applications"
    
  6. Save a description of the new database (again just curious).

    lsregister -dump | less > lsregDumpNew2.txt
    

The new database is now about 1 MB, down from the original 6 MB. There sure was a lot of junk in there!

/mac   〆   permanent link