after_use_textmate 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. #
  3. # Automatically sets the wrappers for textmate's use
  4. # Based on article posted: http://www.christopherirish.com/2010/06/28/how-to-setup-textmate-to-use-rvm/
  5. # Set up the TM_RUBY shell variable as described and remove the Builder as described and restart TextMate
  6. #
  7. # Make this script executable and you should be good to go! TextMate will stay in sync with rvm, which
  8. # generally means the last project folder you switched into from terminal shell.
  9. #
  10. function set_textmate_wrapper()
  11. {
  12. typeset __current_ruby __textmate_ruby
  13. __current_ruby=${RUBY_VERSION:-${GEM_HOME##*/}}
  14. if
  15. __textmate_ruby="$( \which textmate_ruby 2>/dev/null )" &&
  16. [[ -n "${__textmate_ruby:-}" ]]
  17. then
  18. __textmate_ruby="$( readlink "${__textmate_ruby:-}" )"
  19. __textmate_ruby="${__textmate_ruby%/ruby}"
  20. __textmate_ruby="${__textmate_ruby%/bin}"
  21. fi
  22. if
  23. [[ -z "${__textmate_ruby}" || "${__textmate_ruby}" != "${__current_ruby:-}" ]]
  24. then
  25. rvm wrapper ${RUBY_VERSION:-${GEM_HOME##*/}} textmate
  26. fi
  27. }
  28. if
  29. [[ $TM_WRAPPING != "1" ]]
  30. then
  31. export TM_WRAPPING="1"
  32. set_textmate_wrapper
  33. unset TM_WRAPPING
  34. fi