Tip 40Switch Locations in Terminal via Drag and Drop

By clicking and dragging a file or folder onto the Terminal window while holding down Command, you’ll instantly switch to either the folder that you’re dragging or the folder that the file you’re dragging is within. In other words, Terminal will automatically type cd for you and then fill in the path, before hitting Return on your behalf. Give it a try to see what happens, but remember to hold down Command before releasing the mouse button—if you don’t, OS X will simply type within Terminal the entire path to the file or the folder, something that can be useful in itself!

Get Mac Kung Fu, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.