On 3/26/04 1:15 PM, "Eugene Lee" <list-themacintoshguy at fsck.net> wrote: > : #! /bin/sh > > No spaces here, it should be "#!/bin/sh" (without the quotes). OK. Didn't affect the script's running, though. > > : # hide an application in the Finder > : osascript <<END > : tell application "Finder" > : if exists application process "$1" then > : set visible of application process "$1" to false > : end if > : end tell > > To be a proper here document, you must include the ending "END" string. > Otherwise, you cannot follow the AppleScript with more shell commands. > For example, let's show the time when the app was hidden. This script > hides an app but unexpectedly prints the string "date". > > #!/bin/sh > osascript <<END > tell application "Finder" > if exists application process "$1" then > set visible of application process "$1" to false > end if > end tell > > date > > The corrected script hides an app and then runs the "date" command to > show the current time, which is what we intended. > > #!/bin/sh > osascript <<END > tell application "Finder" > if exists application process "$1" then > set visible of application process "$1" to false > end if > end tell > END > date OK. > > : As usual, save this script, with a name such as hide, in a directory that's > : in your PATH, make it executable by typing chmod 755 hide, then you can run > : it as follows: > : > : hide [application name] > : > : You'll need to type the actual application name that the Finder recognizes; > : move your cursor over the Dock to see: for example, Microsoft Word is the > : full name of the Office word processor, and you need to use quotes around > : any application name that contains spaces: > : > : hide "Microsoft Word" > : > : You don't need to respect case; this works even if you type hide safari, for > : example. > : > : ********* > : > : You'll not that I put END on the first line, and that you don't need to have > : another END at the end. > > You really should. See above. Done. > > : Can we take this further and find a way to hide all other applications from > : this script? > > Yep. Here's the basic script. > > #!/bin/sh > osascript <<END > tell application "Finder" > set visible of every process whose visible is true and name is not "Finder" > and name is not "$1" to false > end tell > END > > Remove the 'and name is not "Finder"' string if you want to hide the > Finder as well. Cool! > > Of course with a bit more work, one could make an all-purpose shell > script that could something like this: > > hide [-oaf] appname > > Without options, it will hide the application named "appname". > > The options might be like: > > -o Hide all applications other than "appname". > -a Hide all applications. > -f Hide the Finder. > > where -o and -a by default do *not* hide the Finder. > > Just an idea. What if the script contained an if statement, like this: if name is "o" then [hide others] else if name is "a" then [hide all] else if name is "f" then [hide Finder] Could that be done? If so, you'd have the following syntax: hide o hide a hide f hide [application name] Doable? Kirk My latest book: How to Do Everything with Mac OS X Panther http://www.mcelhearn.com/htde.html . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . kirk at mcelhearn.com | http://www.mcelhearn.com . . . . . . . . Kirk McElhearn | Chemin de la Lauze | 05600 Guillestre | France . .