c52fea808210bb4f81915306855b6bd00a5fe219

Author
Ben Langfeld <ben@langfeld.me>
Committer
Ben Langfeld <ben@langfeld.me>
Date

Message

Make a cleaner version of the OS X tab function

Diff

 1diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
 2index fce88c79669f8169b68c8da25aca707c0ba59f96..eb995eb2efc17cfbc8089e10a5ea810cdacdfc1c 100644
 3--- a/plugins/osx/osx.plugin.zsh
 4+++ b/plugins/osx/osx.plugin.zsh
 5@@ -1,11 +1,32 @@
 6+function savepath() {
 7+  pwd > ~/.current_path~
 8+}
 9+
10 function tab() {
11-  osascript 2>/dev/null <<EOF
12-    tell application "System Events"
13-      tell process "Terminal" to keystroke "t" using command down
14-    end
15-    tell application "Terminal"
16+savepath
17+osascript >/dev/null <<EOF
18+on do_submenu(app_name, menu_name, menu_item, submenu_item)
19+    -- bring the target application to the front
20+    tell application app_name
21       activate
22-      do script with command "cd \"$PWD\"; $*" in window 1
23     end tell
24+    tell application "System Events"
25+      tell process app_name
26+        tell menu bar 1
27+          tell menu bar item menu_name
28+            tell menu menu_name
29+              tell menu item menu_item
30+                tell menu menu_item
31+                  click menu item submenu_item
32+                end tell
33+              end tell
34+            end tell
35+          end tell
36+        end tell
37+      end tell
38+    end tell
39+end do_submenu
40+
41+do_submenu("Terminal", "Shell", "New Tab", 1)
42 EOF
43-}
44+}