Paste a file path into a terminal the easy way
You are in the terminal, mid-command, and you need the path to a file. The file is sitting in a Finder window a few inches away, but between you and the command line stands the job of turning its location into text. Type it out and you will misspell a folder or forget a space. Guess at it and the command fails. The path is simple; getting it into the terminal cleanly is the annoying part.
There are a few good ways to do this on a Mac, and the best one depends on where the file is and how the command is going. Here is what actually works, without fighting the keyboard.
The drag trick, and why it is usually best
The terminal has a built-in shortcut that most commands can use, and it is the one to reach for first.
With your terminal window open, drag any file or folder from Finder and drop it onto the window. The terminal immediately writes out the full path at the cursor, correctly escaped, so a space in a folder name becomes something the shell reads properly instead of breaking your command in two. You can drag in several files in a row to build up a list of arguments. Nothing touches the clipboard, so whatever you had copied before is still there.
This is the quickest route when the terminal is already open and the file is visible. You stay in the flow of typing, drop the file where the path belongs, and carry on. For a one-off command, it is hard to beat.
The limits show up when the windows are not lined up. If the Finder window is buried under other windows, you have to dig it out first, and if you are working over a remote session the local drag does not mean anything on the far end. It is a great trick when the pieces are already in place, and awkward when they are not.
The copy-as-pathname route
When dragging is inconvenient, the clipboard does the job.
In Finder, select the file, right-click, and hold down the Option key. The “Copy” item turns into “Copy as Pathname”. Click it and the full path is on your clipboard as plain text. Switch to the terminal and paste with Command-V. You now have the same escaped, complete path, and it does not matter whether the Finder window is visible any more, because the path is text you carried over.
This route wins when you want the path more than once, or when the file and the terminal cannot easily share the screen. The one thing to watch is that a raw pasted path is not always escaped the way the terminal’s own drag does it, so a name with unusual characters may still need quoting. For ordinary paths it is clean and quick.
What still slows you down
Both methods assume you can get to the file in the first place. In practice you often cannot, not right away. The file you need is an attachment you just saved, or an export sitting in Downloads, or something a colleague sent that is still in the chat app. Before you can drag it or copy its path, you have to go find it and surface it, which is the part that actually eats the time.
The typing problem was never really about typing. It was about the gap between where the file is and where you need its path to appear. Closing that gap is more useful than another way to escape a space.
A shelf that types the path for you
This is the job Ledge takes on. It turns the notch, or the top centre of the screen on a Mac without a notch, into a shelf. When a file lands in your hands, from a download, an email, a chat, you drag it up to that spot and let go, and it waits there. You do not have to keep the Finder window in view, and you do not have to hold the file the whole way to the terminal.
When you are ready, drag the file off the shelf and drop it on your terminal. Ledge hands over the path as text, and it can type that path straight in at the cursor for you. Pasting a path into a terminal this way uses the macOS Accessibility permission, which the app asks for only the first time you drop onto a terminal, never at launch. The same file dropped on a chat app uploads instead, and dropped on a Finder window it moves the file, so you are not choosing a format, just choosing a destination.
The point is that the shelf holds the file between finding it and using it. You surface the file once, park it at the top of the screen, and when the command is ready the path goes in with a drop rather than a hunt.
Picking the right method
For a quick command with the file already in view, the drag trick is the easiest thing on the Mac and needs nothing extra. When the file and the terminal cannot share the screen, copy as pathname and paste. And when the real delay is finding the file and holding onto it while you get to the terminal, a shelf that parks the file at the top of the screen and types the path on drop removes the step that was actually costing you time.