A collection of useful programs I've written for Mac OSX.

GUI Environment Variables on OS X and macOS

With the advent of launchd and user launch agents, setting multiple environment variables that are available to your GUI applications is as simple as creating this plist file ~/Library/LaunchAgents/local.launchd.environment.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>local.launchd.environment<</string>
        <key>Disabled</key>
        <false/>
        <key>RunAtLoad</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
            <string>/bin/sh</string>
            <string>-c</string>
            <string>for env in "$@" ; do eval $env ; done</string>
            <string>/bin/sh</string>
            <string>launchctl setenv ANT_HOME /usr/local/apache-ant-1.9.6</string>
            <string>launchctl setenv CATALINA_HOME "$HOME/Projects/apache-tomcat-8.0.24"</string>
        </array>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
        <key>StandardOutPath</key>
        <string>/dev/null</string>
</dict>
</plist>

You can add as many <string>launchctl setenv ... </string> statements as required, one for each environment variable.

Copyright © 1988-2011, Paul A. Scott, All rights reserved.

Archive

Archive is a script-application that creates a zip archive of one or more files and/or directories with all the Mac meta-data and Finder's hidden files left out. Normal files and directories, hidden or otherwise, are included in the zip archive.

Archive is preferable to the built-in Compress context menu item when the zip archive's intended recipient is a non-Mac user because it removes "clutter" from the archive. Conversely, the built-in Compress feature is preferable to Archive if the intended recipient is a Mac user because that "clutter" is, in reality, valuable information.

Disclaimer: If you destroy an existing archive because you didn't read this page in its entirety, it's your own damn fault. If you did read this page in it's entirety and destroy an existing archive, it's still your own damn fault!

Installation

There is no package installer. Instead, download the zipped script application bundle. It should automatically unzip and leave the script application bundle exposed. Please be aware that the script application bundle icon makes it look like a zip archive, but "Get Info" will show that it's actually an application named "Archive.app". Move the script application bundle to your Scripts folder.

~/Library/Scripts/Archive.app

If you have not previously enabled the script menu in your menu bar, do that now by running the AppleScript Editor, select Preferences, and then check "Show Script menu in menu bar".

Usage

To create a zip archive, highlight one or more files and/or directories, then select "Archive" from the script menu in the menu bar. That's it! Note, however, that this simplicity implies certain important rules:

Uninstall

Remove the script-application:

~/Library/Scripts/Archive.app

Copyright © 1988-2011, Paul A. Scott, All rights reserved.

Compress PDF

To restore the "Compress PDF" workflow to the Print dialog in OS X Snow Leopard install this package from an account with administrator privileges. This restores the Tiger functionality that Leopard ate.

If you are running OS X Leopard, install this older package instead.

Please ignore any instructions on installing this workflow that you may have read somewhere else. This new package obsoletes those instructions. When the installer says, "Finished," the package is installed and ready to use.

N.B.: This workflow works by compressing images. If your document does not contain images, or its images are already optimized, then your resulting PDF may be larger than one created without this workflow. In other words, don't expect that every PDF file can be made smaller; you must apply some thought to the problem beforehand.

To uninstall the Compress PDF workflow, remove the following file:

/Library/PDF Services/Compress PDF.workflow

If you installed an older version you may also need to uninstall these files (the tilde indicates your home directory):

~/Library/PDF Services/Compress PDF.workflow
~/Library/Filters/Compress PDF.qfilter

Copyright © 1988-2011, Paul A. Scott, All rights reserved.

Shrink Universal Binary

Download the compressed archive, expand it, and run the workflow to remove the all architectures except the machine architecture from the files you choose. For example, PPC will be removed on an Intel machine, and Intel will be removed on a PPC machine. Be careful not to shrink libraries that might be needed to run applications under Rosetta.

Copyright © 1988-2011, Paul A. Scott, All rights reserved.