1

Is there a way that I can grab the status of com.apple.Finder AppleShowAllFiles in command line?

I switch between AppleShowAllFiles yes & no frequently, I want to write a .command file to check if it's yes then switch to no and vice versa. I now get stuck at query the status of AppleShowAllFiles.

2

1 Answer 1

1

Thank you for comment from @Yoric

I found the answer from stackoverflow @Carter Allen

#!/bin/bash
#toggle AppleShowAllFiles

current_value=$(defaults read com.apple.finder AppleShowAllFiles)
if [ "$current_value" = TRUE ]
then
  defaults write com.apple.finder AppleShowAllFiles FALSE
else
  defaults write com.apple.finder AppleShowAllFiles TRUE
fi

killall Finder
1
  • FWIW The AppleShowAllFiles key by default does not exist, so as coded the script fails if it had never been set previous. Also you didn't say what version of OS X/macOS you're running however, this is no longer needed since (IIRC) macOS Sierra and later has the keyboard shortcut of ⇧⌘. to toggle the state of hidden files as needed. Commented Jan 14, 2019 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .