Published at
Updated at
Reading time

I saw an interesting discussion on Twitter today. People were talking about messy desktops and the always full Downloads folder on macOS. These two directories are usually full of two different file types: random internet downloads and lots of screenshots.

Let me tell you a secret! I didn't need to clean up ~/Downloads or ~/Desktop for a year now because I changed a few macOS settings. There are two tricks to get rid of the problem of too many files on your hard drive.

Say hi to /tmp (or /private/tmp)

Here's the thing. On macOS, there's the /tmp directory. This directory is used for temporary operating system files, and it's automatically cleaned up after you reboot your machine.

When you navigate to / and list the files and directories in that location, you see that /tmp is symlinking to /private/tmp.

Directory listing of / showing that tmp is a symlink to private/tmp

I don't know enough about the symlink's historical reasons, but I'm using the /tmp directory every day. It doesn't matter if I'm setting up a quick coding prototype or download random files. When I know that I don't want to keep files, I place them there and forget about them.

The /tmp directory is the solution to the problem of a hard drive full of random stuff.

macOS finder showing a tmp sidebar shortcut

To access /tmp quickly, I added a shortcut to my macOS Finder, too.

Store downloads in a directory that's automatically cleaned up

I configured my main browser (Firefox) to store downloads by default in /private/tmp, too.

Firefox settings routing downloads to /private/tmp

Whenever I download a file, I can look at it, close it and call it a day. 🎉 And when the file is important, I'll move or save it in the correct location (which you have to do anyways when Downloads is the default).

Copy screenshots to the clipboard instead of saving them to disk

By default, macOS stores screenshots at ~/Desktop. Many programs and websites that I use (Keynote, Slack, Twitter, etc.) allow uploading images directly from the clipboard by hitting paste. I flipped the macOS shortcut settings in the keyboard preferences to copy a screenshot to the clipboard instead of creating a new file. By default ⇧⌘3 and ⇧⌘4 create a new screenshot png file.

My flipped configuration is:

  • ⇧⌘3 copy picture of screen to the clipboard
  • ^⇧⌘3 save picture of screen as file
  • ⇧⌘4 copy picture of selected area to the clipboard
  • ^⇧⌘4 save picture of selected area as file

Shortcut settings to copy screenshot to clipboard in macOS

This setting works perfectly. There's no unnecessary file going anywhere on my computer for the programs allowing me to paste images.

And if I really need to save a screenshot to disk because a website is not supporting "paste upload", I changed the settings and the image is stored in /tmp, too.

To adjust the screenshot location, you have run the command below in your terminal.

echo "Store screenshots in /tmp"
defaults write location /tmp

(if you're curious about more macOS settings, have a look at my dotfiles).

With these two settings, I'm leveraging the /tmp directory to stop worrying about overflowing directories on my machine. I only have to deal with files being stored on my hard drive when I know I want to keep them.

Was this post helpful?
Yes? Cool! You might want to check out Web Weekly for more web development articles. The last edition went out 10 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles