osx.plugin.zsh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. function savepath() {
  2. pwd > ~/.current_path~
  3. }
  4. function tab() {
  5. savepath
  6. osascript >/dev/null <<EOF
  7. on do_submenu(app_name, menu_name, menu_item, submenu_item)
  8. -- bring the target application to the front
  9. tell application app_name
  10. activate
  11. end tell
  12. tell application "System Events"
  13. tell process app_name
  14. tell menu bar 1
  15. tell menu bar item menu_name
  16. tell menu menu_name
  17. tell menu item menu_item
  18. tell menu menu_item
  19. click menu item submenu_item
  20. end tell
  21. end tell
  22. end tell
  23. end tell
  24. end tell
  25. end tell
  26. end tell
  27. end do_submenu
  28. do_submenu("Terminal", "Shell", "New Tab", 1)
  29. EOF
  30. }
  31. function itab() {
  32. savepath
  33. osascript >/dev/null <<EOF
  34. on do_submenu(app_name, menu_name, menu_item)
  35. -- bring the target application to the front
  36. tell application app_name
  37. activate
  38. end tell
  39. tell application "System Events"
  40. tell process app_name
  41. tell menu bar 1
  42. tell menu bar item menu_name
  43. tell menu menu_name
  44. click menu item menu_item
  45. end tell
  46. end tell
  47. end tell
  48. end tell
  49. end tell
  50. end do_submenu
  51. do_submenu("iTerm", "Shell", "New Tab")
  52. EOF
  53. }