How to hide Finder's dock icon on login when using Path Finder

I’ve been using the excellent Finder replacement “Path Finder” recently, and so far I only have one complaint. While it allows you to enable the Finder’s “Remove from Dock” context menu option, it doesn’t offer any way to do this automatically. Unfortunately, Finder forces itself back onto your dock every time you log in. To fix this, I wrote a simple AppleScript to replace Path Finder’s login item.

Configuring Path Finder

The first order of business is to stop Path Finder from automatically launching on startup. You can do this in its preferences:

Uncheck Launch Path Finder At Startup

Next, make sure Path Finder adds the “Remove from Dock” option to Finder’s contextual menu in the dock:

Check Enable Finder's Remove from Dock Menu Option

Creating the AppleScript

Open the AppleScript Editor and save the following as a new script or application:

on run
    tell application "Path Finder" to launch
    repeat until application "Path Finder" is running
        delay 1
    end repeat
    try
        tell application "System Events" to tell UI element "Finder" of list 1 of process "Dock"
            perform action "AXShowMenu"
            click menu item "Remove from Dock" of menu 1
        end tell
    on error
        -- Suppress errors if Finder isn't in dock
    end try
end run

Finally, open System Preferences > Users & Groups > Login Items and add your script:

Add the script to Login Items

That’s all there is to it! Now when you log in, OS X will launch Path Finder and automatically hide the Finder icon from the dock.