If you’re like most Mac users, you probably spend a lot of time in the terminal. Terminal is a powerful tool that can do everything from managing your files to troubleshooting your computer. But even with all its power, terminal can be slow and tedious to use. One way to speed up your terminal commands is by using drag and drop. With drag and drop, you can quickly move files between your computer and the terminal window. Here’s how it works:
- Open the terminal window.
- In the terminal window, type the command you want to use. For example, to list all of your files in the current directory, type ls .
- To move a file from one location on your computer to the terminal window, drag it from its location on your computer into the terminal window. The file will automatically be opened in the terminal window.
- To delete a file from your computer, drag it out of the terminal window and release it when it drops onto the desktop or another area on your computer. ..
Drag and Drop Files and Folders
Terminal requires that you type commands in order to perform actions, but these commands need to be typed perfectly to execute. One of the easiest mistakes to make when typing a command is to get the location of a file or folder wrong.
This is especially true when folders have spaces in their names since you need to “escape” the space. For example, ~/Documents/My Stuff must be typed as ~Documents/My\ Stuff/ instead.
Instead of typing the location, you can drag and drop it. When you do this, you’ll insert the exact file location into your current command, wherever the cursor is.
You can use this for individual files by dragging and dropping them into the Terminal window. You can also do it for folders, including icons in the title bar of a folder window (Click and drag the small folder icon that appears next to the folder name.).
As an alternative to drag and drop, you can copy the file or folder in Finder and then use the paste shortcut (Command+V) in Terminal to insert the location instead.
RELATED: How to Open Terminal in the Current OS X Finder Location
Some Example Uses for This Tip
This is useful for inserting precise file names and long pathnames into commands. For example, if you download a Linux ISO file that you need to convert into a DMG file using the hdiutil convert command, you can drag the ISO from your Downloads stack in the macOS dock directly into Terminal.
It’s also possible to use drag and drop functionality as you would other apps that are pinned to the dock. For example, if you drag and drop a folder onto the Terminal icon, you’ll cd (change directory) to that folder immediately.
Do More with the Mac Terminal
A basic understanding of some macOS Terminal commands can go a long way. There’s ample built-in help documentation at a system level, and tips like drag and drop can dramatically speed up some processes.
If you’ve never touched the macOS Terminal before, then you owe it to yourself to check out the Linux-inspired Homebrew package manager.
RELATED: 16 Terminal Commands That Every Mac User Should Know