How to copy Unix file path in OS X Yosemite

Solution 1:

Just select the file itself in Finder and press CmdC or go to Edit » Copy. You can then paste the path directly to a terminal window.

Note that this will escape special characters.

If you want the path in human-readable form, you need to do the following:

  • Open Utilities/Automator.app
  • Create a new Service
  • Set it to receive no input from Finder.app
  • Drag Run AppleScript from the left pane to the right
  • Paste the following into the field:

    tell application "Finder"
        set sel to the selection as text
        set the clipboard to POSIX path of sel
    end tell
    
  • It should look like this:

  • Save the service under any name you like, e.g. Copy human-readable path.

This is part one. Now, set a keyboard shortcut:

  • Head to  » System Preferences » Keyboard » Shortcuts
  • Go to the Services section and scroll down
  • Set a keyboard shortcut for your service

Et voilà, now press that shorcut when you need the path of any selected Finder item.

Solution 2:

Open up the “Terminal” in Applications > Utilities > Terminal and then drag the file into the window. The full Unix path of the file will show up.