Thread: Scripted RC
View Single Post
  #35  
Old 04-27-2008, 02:48 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Stefan View Post
For Mac and Linux that would require some more work, but at least the normal editing of text should be enabled.
It would be very easy on Mac; the OS X developers have a command line tool which is used by Finder to open files and applications. You would just use an exec call:
HTML Code:
Usage: open [-e] [-t] [-f] [-W] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.  
      If the file is in the form of a URL, the file will be opened as a URL.
Options: 
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
      -n, --new         Open a new instance of the application even if one is already running.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.
For instance:
HTML Code:
$ open test.txt
... opens test.txt either in the application it is associated with (some files have metadata which contains the program it was created in), or the default selected application otherwise.

The `open' command is not blocking unless you use the -W option; it terminates automatically once the new program has been opened successfully. The application appears as normal in the Dock though, or opens the document in the existing application process if it is already open.
Reply With Quote