#!/bin/bash
k="com.apple.Finder AppleShowAllFiles"
b=$(defaults read $k 2>&1 /dev/null)
[[ "$b" == 1 ]] && b=false || b=true
defaults write $k -bool $b
osascript -e 'tell app "Finder"
quit
delay 0.2
launch
activate
end'
Ou uma versão do AppleScript:
set k to "com.apple.finder AppleShowAllFiles"
set r to do shell script "defaults read " & k
do shell script "defaults write " & k & " -bool " & (r is 0 as text)
tell application "Finder"
quit
delay 0.2
launch
delay 0.2
activate
end tell