Skip to content

Instantly share code, notes, and snippets.

Last active December 2, 2022 18:09
What would you like to do?
Quickly show/hide desktop icons on macos
# To install: just copy this script to your machine and name it whatever you want.
# Let's say you named it, then all you need to do is make
# the script executable, like this:
# chmod +x
# Now you can execute the script directly in the terminal any time you want to
# show/hide the desktop icons, like this:
# ./
prevValue=$(defaults read CreateDesktop 2>&1)
nextValue=$([[ "$prevValue" == "true" || "$prevValue" == *"does not exist"* ]] && echo "false" || echo "true")
if [[ "$nextValue" == "true" ]]; then
echo "Showing desktop icons..."
echo "Hiding desktop icons..."
defaults write CreateDesktop $nextValue
killall Finder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment