sublime.plugin.zsh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if [[ $('uname') == 'Linux' ]]; then
  2. local _sublime_linux_paths > /dev/null 2>&1
  3. _sublime_linux_paths=(
  4. "$HOME/bin/sublime_text"
  5. "/opt/sublime_text/sublime_text"
  6. "/opt/sublime_text_3/sublime_text"
  7. "/usr/bin/sublime_text"
  8. "/usr/local/bin/sublime_text"
  9. "/usr/bin/subl"
  10. "/opt/sublime_text_3/sublime_text"
  11. "/usr/bin/subl3"
  12. )
  13. for _sublime_path in $_sublime_linux_paths; do
  14. if [[ -a $_sublime_path ]]; then
  15. st_run() { $_sublime_path $@ >/dev/null 2>&1 &| }
  16. st_run_sudo() {sudo $_sublime_path $@ >/dev/null 2>&1}
  17. alias sst=st_run_sudo
  18. alias st=st_run
  19. break
  20. fi
  21. done
  22. elif [[ "$OSTYPE" = darwin* ]]; then
  23. local _sublime_darwin_paths > /dev/null 2>&1
  24. _sublime_darwin_paths=(
  25. "/usr/local/bin/subl"
  26. "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
  27. "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
  28. "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
  29. "$HOME/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
  30. "$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
  31. "$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
  32. )
  33. for _sublime_path in $_sublime_darwin_paths; do
  34. if [[ -a $_sublime_path ]]; then
  35. subl () { "$_sublime_path" $* }
  36. alias st=subl
  37. break
  38. fi
  39. done
  40. elif [[ "$OSTYPE" = 'cygwin' ]]; then
  41. local _sublime_cygwin_paths > /dev/null 2>&1
  42. _sublime_cygwin_paths=(
  43. "$(cygpath $ProgramW6432/Sublime\ Text\ 2)/sublime_text.exe"
  44. "$(cygpath $ProgramW6432/Sublime\ Text\ 3)/sublime_text.exe"
  45. )
  46. for _sublime_path in $_sublime_cygwin_paths; do
  47. if [[ -a $_sublime_path ]]; then
  48. subl () { "$_sublime_path" $* }
  49. alias st=subl
  50. break
  51. fi
  52. done
  53. fi
  54. alias stt='st .'