html_browser_mac.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. # open a help file in the browser specified in GRASS_HTML_BROWSER_MACOSX. A
  3. # script is used so that it operates like other platforms - all it takes
  4. # is the browser executable command and the file to open. If it's a web URL,
  5. # open in the user's default browser instead, since Help Viewer will do that
  6. # anyways, yet leave an empty Help Viewer window open.
  7. #
  8. # William Kyngesburye
  9. # Application (.app) executables can't be run directly from the CLI, or they
  10. # will start as a new process, instead of opening a new window or activating
  11. # the application. The proper method is to use open with the application
  12. # package as an argument. This can be done in two ways:
  13. #
  14. # open -a /path/to/application.app /file/to/open
  15. #
  16. # or:
  17. #
  18. # open -b app.signature /file/to/open
  19. #
  20. # for some known apps it's simpler to use the second option. Whatever is
  21. # used should be taken care of in init.sh.
  22. #
  23. # For html files, when using app path method, open still wants to open the
  24. # file in the system default browser, so we're left with signatures-only.
  25. if [ ! "$GRASS_HTML_BROWSER_MACOSX" ] ; then
  26. # default to Help Viewer
  27. GRASS_HTML_BROWSER_MACOSX="-b com.apple.helpviewer"
  28. fi
  29. if [ "`echo \"$1\" | grep 'https\?://'`" ] && [ "$GRASS_HTML_BROWSER_MACOSX" = "-b com.apple.helpviewer" ] ; then
  30. open "$1"
  31. else
  32. open $GRASS_HTML_BROWSER_MACOSX "$1"
  33. fi