I've never created a script before and am looking for a tutorial on writing a script for OSX 10.6. There is a terminal command that can show all hidden files. It's
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Changing TRUE to FALSE will hide system files. I want to make a script that checks the value of AppleShowAllFiles, and if TRUE, writes FALSE, and if FALSE, writes TRUE.
Is this done in TextEdit and saved as a .sh file? Can a script be something I double-click that just runs, or do I have to start terminal and type a command to execute the script? I'm a newb, sorry
Thanks guys
You can use the .command
extension to turn it into something you can click on. Just be sure to save it as text-only (Format -> Make Plain Text in TextEdit).
make a file switchhideshow.command with the following content:
#!/bin/sh
show=`defaults read com.apple.Finder AppleShowAllFiles 2>/dev/null`
if [ "$show" == "TRUE" ]; then
defaults write com.apple.Finder AppleShowAllFiles FALSE
else # here we come, if it is FALSE or is empty (the default)
defaults write com.apple.Finder AppleShowAllFiles TRUE
fi
killall Finder
then: chmod a+x switchhideshow.command
Ready. Unfortunately, you should close the terminal every time you run it. Also, you might want to look at this . It describes how to call the shell script to show hidden files from Automator Actions.
Have a look at Platypus ; it will wrap up many different kinds of scripts into proper OS X applications.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.