brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: drag a file from Finder into Terminal to type its full path

Terminal
~/tips/tip-terminal-drag-file-path

cd /Users/me/Downloads/Old\ Projects\ 2024

Puts the complete, escaped path of a Finder item on your command line.

Long paths with spaces are a pain to type, and Tab completion still makes you walk every folder. Finder already knows where the file is.

Start your command, leave a space, and drag the file or folder from Finder onto the Terminal window. Terminal types the complete path at the cursor, with spaces escaped by backslashes:

cd /Users/me/Downloads/Old\ Projects\ 2024

Drag several files at once and they all land on the line, separated by spaces. It works for items from the desktop, from a Finder search result and from the proxy icon in a document’s title bar too. That last one is handy when a file is already open in Preview or TextEdit and you can’t remember where it lives.

For anything in Downloads I’d pick this over Tab completion. The reverse is just as quick: open . opens the current folder in Finder, so you can go back and forth.

Watch where the cursor is before you drop. The path goes wherever the cursor sits, so dropping at the start of a line gives you a command that starts with a file name. Some programs that run in the terminal, like vim in insert mode, get the path as typed text too, which is useful or confusing depending on the moment.

Further reading: Keyboard shortcuts in Terminal on Mac (Apple Support)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link