Tips & tricks · Workflow · Everywhere · ~2 min a day · 2 min read
Stop retyping file paths: drag the file into the terminal
Last reviewed:

Typing out a file path is the most error-prone thing you do in a terminal: long folder names, spaces, accented characters — and a single typo means No such file or directory. Yet there's a trick surprisingly few people know: just drag a file or folder with the mouse from File Explorer, Finder, or another file manager straight into the terminal window. The terminal inserts the full path at the cursor position, and best of all, correctly escaped — it quotes or escapes spaces and special characters for you.
How to do it
- Type the start of a command into the terminal, say
unzip(with a trailing space). - Find the file in File Explorer (Windows), Finder (Mac), or your file manager (Linux) and drag it with the mouse into the terminal window.
- The full path appears on the line — for example
'/home/jane/Downloads/project materials.zip'— quotes around the spaces included. Press Enter. - It works in Windows Terminal, in macOS Terminal and iTerm, and in most Linux terminals. You can drag a folder too — handy for
cd: typecd, drag the folder, Enter. - On a Mac, the trick has a sibling: whenever you see a file in an open dialog or window in any app, you can also get its path into the terminal via Cmd+Option+C in Finder.
A typical scenario
A student needs to run a script in the terminal on a file that arrived by email: Measurement Results – Group B (final version).csv, saved somewhere in Downloads. Typing that path by hand is practically impossible — spaces, a dash, parentheses, accented letters, every character a trap. Instead, he types python analyze.py , drags the file from the folder into the terminal, and runs it. Ten seconds, zero typos.
The same trick pays off for commands involving two paths at once — like cp or ffmpeg: type the command, drag the source file, type the destination. It also works with tools that prompt interactively for a file: anywhere the terminal is waiting for a path, you can drop a file instead of typing.
It's worth knowing that dragging only inserts the path text — the file itself isn't copied or moved anywhere, so there's no risk of scattering anything. The terminal and the graphical world, which usually live apart, suddenly shake hands.
What you get out of it
The most common source of terminal errors — hand-typed paths — disappears. Files with spaces and accented characters in their names stop being a problem, because the terminal handles the quoting itself. And the barrier for occasional users drops: you don't need to know tab completion or quoting rules, just how to drag with a mouse — the terminal instantly becomes friendlier even to someone who spends five minutes a week in it.
Want to go deeper? The handbook has a whole chapter on it — Core systems: inbox, priorities, reviews.
Similar tips
git add -p: Commit in Chunks, Not Whole Files
One file has both a bug fix and an unrelated cleanup? git add -p walks through the changes chunk by chunk and asks what belongs in the commit.
git commit --amend: Fix the Last Commit Instead of Committing a “Fix”
A forgotten file or a typo in the message doesn't need a new commit. --amend rewrites the last one, as if the mistake never happened.
A Global .gitignore: Solve .DS_Store Once and For All
Files from your system and editor don't belong in every project's .gitignore. Set up a global ignore file instead — it applies to every repository.
Was this helpful?
Liked this tip?
I send one like it every week by email. Two minutes to read, hours saved.
1 tip a week · no spam · unsubscribe in one click