You can use Automator to do this with a single keyboard shortcut that you can use from any app, and without installing 3rd party software.
This Automator Service will copy the path of the Finder's front window, rather than the path of a selected file or folder, so it won't affect what windows are open or what items are selected. The path that is copied is simply text, so it can be pasted anywhere that you can paste text.
- Open Automator and create a new Service.
- Change "Service receives selected" to
no input (or "files or folders" to have it appear from a right click) and leave it set to
any application (unless you only want it to work from a specific app, like the Finder).
- Add a "Run AppleScript" action to the workflow.
(* Your script goes here *) with:
tell application "Finder" to set the clipboard to POSIX path of (target of window 1 as alias)
Save the Automator Service with whatever name you'd like it to have in the Services menu.
This Automator Service will now be in your Services menu.
Note: This doesn't escape spaces, so if your path has spaces, you may need to quote it. For example, in Terminal, the path would need to be quoted, but in Finder's "Go to Folder" command, it would not. If you want it to copy as quoted, you can change
POSIX path to
quoted form of POSIX path.
You can add a keyboard shortcut for the service by going to System Preferences > Keyboard > Keyboard Shortcuts, then click on "Services" in the left pane, then scroll down to the "General" section in the right pane until you find your service.