![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to display only hidden files | useless79 | Shell Programming and Scripting | 7 | 11-12-2008 05:50 AM |
| Hidden Files in Linux | Arun.Kakarla | UNIX for Dummies Questions & Answers | 3 | 07-05-2008 04:45 PM |
| find excluding the hidden files | arunkumar_mca | UNIX for Advanced & Expert Users | 3 | 01-27-2008 11:45 PM |
| Finding Hidden files and protecting the folder containing hidden files from deletion | pochaw | Shell Programming and Scripting | 4 | 12-22-2007 01:33 AM |
| Transferring hidden files with scp | matrixmadhan | UNIX for Dummies Questions & Answers | 13 | 01-16-2007 04:00 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Toggle Hidden Files Mac OS X
Hi all,
I have been using Ubuntu for 2 years now, and a few days ago I bought a Macbook. This is my first time using a Mac, so I have spent the better of two days learning the user interface, and configuring my Macbook. One thing I noticed is that there is no easy way to turn on and off hidden files, so I wrote a shell script to make it easy. This is my first time ever making a script (I have previously never written a script on any OS), I hope you guys can comment on it, tell me whats good, bad, and how it can be done differently. Specifically: -Why does my terminal not close after the script is complete? -Whats the best way to restart an application, ie one example has killall, the other uses osascript and envokes the quit command? -Which application is safer? -I named these files .command files so they can execute on double click, is the the best way to do it? -Why do I have to execute 'open -a Finder' twice? Code:
Example 1
#!/bin/sh
# This Application Makes Hidden Files Visible
# Note: The Application Will Close All Finder Windows
echo Warning This Application Will Close All Finder Windows!
echo Type y/n to Continue?
read answer
if [ "$answer" = "y" ]
then
filesVisible=$(defaults read com.apple.finder AppleShowAllFiles)
if [ "$filesVisible" = "0" ]
then
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder
else
defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder
fi
else
exit
fi
exit
Code:
Example 2
#!/bin/sh
# This Application Makes Hidden Files Visible
# Note: The Application Will Close All Finder Windows
echo Warning This Application Will Close All Finder Windows!
echo Type y/n to Continue?
read answer
if [ "$answer" = "y" ]
then
filesVisible=$(defaults read com.apple.finder AppleShowAllFiles)
if [ "$filesVisible" = "0" ]
then
defaults write com.apple.finder AppleShowAllFiles -bool true
osascript -e 'tell app "Finder" to quit'
open -a Finder
open -a Finder
else
defaults write com.apple.finder AppleShowAllFiles -bool false
osascript -e 'tell app "Finder" to quit'
open -a Finder
open -a Finder
fi
else
exit
fi
exit
Omniwheel |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|