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.

Nimesh Neema
  • 51,809
Yang
  • 21
  • It sounds like this script: https://stackoverflow.com/questions/5206008/toggle-appleshowallfiles-with-a-simple-bash-script – Yoric Jan 11 '19 at 07:20
  • The question is slightly different, but this includes several methods, covering several macOS versions [the method changes depending on OS] - https://apple.stackexchange.com/questions/258733/how-to-show-hidden-files-on-mac-without-terminal/ – Tetsujin Jan 11 '19 at 07:29

1 Answers1

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
fd0
  • 10,708
Yang
  • 21
  • 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. – user3439894 Jan 14 '19 at 14:48