Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

startup_macosx.sh.in 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  1. #!/bin/bash
  2. # Startup script for GMT.app in MacOSX.
  3. # Setup environment and start Terminal.
  4. if [ "$1" = "GMT_PROMPT" ]; then
  5. _rundir=$(dirname "$0")
  6. cd "${_rundir}/.."
  7. export BUNDLE_RESOURCES="${PWD}/Resources"
  8. cd "${OLDPWD}"
  9. export PATH="${BUNDLE_RESOURCES}/@GMT_BINDIR@:${PATH}"
  10. function gmt () { "${BUNDLE_RESOURCES}/@GMT_BINDIR@/gmt" "$@"; }
  11. export -f gmt
  12. source "${BUNDLE_RESOURCES}/share/tools/gmt_functions.sh"
  13. unset DYLD_LIBRARY_PATH
  14. gmt
  15. _usershell=$(dscl . -read "/Users/$USER" UserShell)
  16. _usershell=${_usershell##* }
  17. if [ ${_usershell} = ${_usershell%bash} ]; then
  18. # not using bash as default shell
  19. echo -e "Warning: your default shell is ${_usershell}. GMT module commands are only available in BASH. Change your default shell or make sure ${BUNDLE_RESOURCES}/@GMT_BINDIR@ is in your PATH and use ${BUNDLE_RESOURCES}/share/tools/gmt5syntax to convert your old GMT scripts.\n"
  20. exec ${_usershell}
  21. fi
  22. # bash: start interactive shell and source gmt completions
  23. _temp_bashrc=$(mktemp -t temp_bashrc)
  24. cat << EOF > "${_temp_bashrc}"
  25. rm -- "${_temp_bashrc}"
  26. test -f ~/.bashrc && source ~/.bashrc
  27. source "${BUNDLE_RESOURCES}/share/tools/gmt_completion.bash"
  28. unset DYLD_LIBRARY_PATH
  29. EOF
  30. exec /bin/bash --rcfile "${_temp_bashrc}" -i
  31. fi
  32. # run terminal, set path, and run gmt
  33. # http://hintsforums.macworld.com/showthread.php?t=68252
  34. osascript << EOF
  35. tell application "System Events"
  36. if (count (processes whose bundle identifier is "com.apple.Terminal")) is 0 then
  37. tell application "Terminal"
  38. do script with command "/bin/bash \"${BASH_SOURCE[0]}\" GMT_PROMPT" in window 0
  39. end tell
  40. else
  41. tell application "Terminal"
  42. do script with command "/bin/bash \"${BASH_SOURCE[0]}\" GMT_PROMPT"
  43. end tell
  44. end if
  45. tell application "Terminal"
  46. activate
  47. end tell
  48. end tell
  49. EOF
  50. exit 0
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...