You can use AppleScript to create drag and drop icons for shell scripts or X11 applications. Here's how you would create a drag and drop icon for Emacs in Terminal.app:
set filecount to 0
on open filelist
repeat with i in filelist
set filecount to 1
tell application "Terminal"
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
do script "emacs " & filename & "; exit"
end tell
end repeat
end open
if filecount < 1 then
tell application "Terminal"
do script "emacs; exit"
end tell
end if
This line:
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
is in there to deal with filenames which have spaces or special characters. POSIX path is the UNIX path of a file; the perl -e replaces /Users/foo/file with spaces in its name with /Users/foo/file\ with\ spaces\ in\ its\ name.
tell application "Terminal"
do script "foo"
end tell
The above will run a script in a Terminal window. But sometimes, you don't want to open a Terminal window. In those cases, use this AppleScript code:
do shell script "foo"
Note that if you've modified your $PATH in your ~/.profile, do shell script won't see your new $PATH. In order to run something that's not in /usr/bin, /bin, /usr/sbin, or /sbin, you'll need to do something like this:
do shell script "source ~/.profile; foo"
That's what to do if you use bash (like me). I'm not sure what you would do if you use tcsh and your $PATH has been edited in your ~/.cshrc.
set filecount to 0
run application "X11"
on open filelist
repeat with i in filelist
set filecount to 1
set filename to do shell script ¬
"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
do shell script "source ~/.profile; xemacs -display :0.0 " & filename & " &"
end repeat
end open
if filecount < 1 then
do shell script "source ~/.profile; xemacs -display :0.0"
end if
This script assumes that the $PATH variable has been altered in ~/.profile to include the directory which xemacs is in.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20031027142625782