Show and Hide Desktop Icons on MacOS

If you wish to keep your MacOS desktop clean and free from any distractions, you can easily toggle the visibility of desktop icons. Below, I've provided two scripts that allow you to hide or show the desktop icons.

Show Desktop Icons

Create a new file named show_icons.sh and copy-paste the following content into it:

#!/bin/bash
defaults write com.apple.finder CreateDesktop true
killall Finder

Hide Desktop Icons

Create another new file named hide_icons.sh and copy-paste the following content into it:

#!/bin/bash
defaults write com.apple.finder CreateDesktop false
killall Finder

Making the Scripts Executable

Once you've created the scripts, you need to grant them permission to be executed. Run the following commands in your terminal:

chmod +x show_icons.sh
chmod +x hide_icons.sh

Using the Scripts

To show the desktop icons, simply run:

./show_icons.sh

And to hide the icons:

./hide_icons.sh