f401d6ef78a94b723ce841b77151eaac477b8074

Author
Sorin Ionescu <sorin.ionescu@gmail.com>
Committer
Sorin Ionescu <sorin.ionescu@gmail.com>
Date

Message

Vastly improved osx plugin.

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
  2index a65ca642a2cc31d89507274fe8714933d17b7281..682bb2667bc2cec79c6edd5870d4d42c871844f2 100644
  3--- a/plugins/osx/osx.plugin.zsh
  4+++ b/plugins/osx/osx.plugin.zsh
  5@@ -1,63 +1,99 @@
  6-alias showfiles='defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder'
  7-alias hidefiles='defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder'
  8+# ------------------------------------------------------------------------------
  9+#          FILE:  osx.plugin.zsh
 10+#   DESCRIPTION:  oh-my-zsh plugin file.
 11+#        AUTHOR:  Sorin Ionescu (sorin.ionescu@gmail.com)
 12+#       VERSION:  1.0.1
 13+# ------------------------------------------------------------------------------
 14 
 15-# Recursively delete .DS_Store files
 16-alias rm-dsstore="find . -name '*.DS_Store' -type f -delete"
 17-
 18-function savepath() {
 19-  pwd > ~/.current_path~
 20-}
 21 
 22 function tab() {
 23-savepath
 24-osascript >/dev/null <<EOF
 25-on do_submenu(app_name, menu_name, menu_item, submenu_item)
 26-    -- bring the target application to the front
 27-    tell application app_name
 28-      activate
 29-    end tell
 30-    tell application "System Events"
 31-      tell process app_name
 32-        tell menu bar 1
 33-          tell menu bar item menu_name
 34-            tell menu menu_name
 35-              tell menu item menu_item
 36-                tell menu menu_item
 37-                  click menu item submenu_item
 38-                end tell
 39-              end tell
 40-            end tell
 41-          end tell
 42-        end tell
 43+  local command="cd \\\"$PWD\\\""
 44+  (( $# > 0 )) && command="${command}; $*"
 45+
 46+  the_app=$(
 47+    osascript 2>/dev/null <<EOF
 48+      tell application "System Events"
 49+        name of first item of (every process whose frontmost is true)
 50       end tell
 51-    end tell
 52-end do_submenu
 53+EOF
 54+  )
 55 
 56-do_submenu("Terminal", "Shell", "New Tab", 1)
 57+  [[ "$the_app" == 'Terminal' ]] && {
 58+    osascript 2>/dev/null <<EOF
 59+      tell application "System Events"
 60+        tell process "Terminal" to keystroke "t" using command down
 61+        tell application "Terminal" to do script "${command}" in front window
 62+      end tell
 63 EOF
 64-}
 65+  }
 66 
 67-function itab() {
 68-savepath
 69-osascript >/dev/null <<EOF
 70-on do_submenu(app_name, menu_name, menu_item)
 71-    -- bring the target application to the front
 72-    tell application app_name
 73-      activate
 74-    end tell
 75-    tell application "System Events"
 76-      tell process app_name
 77-        tell menu bar 1
 78-          tell menu bar item menu_name
 79-            tell menu menu_name
 80-              click menu item menu_item
 81-            end tell
 82+  [[ "$the_app" == 'iTerm' ]] && {
 83+    osascript 2>/dev/null <<EOF
 84+      tell application "iTerm"
 85+        set current_terminal to current terminal
 86+        tell current_terminal
 87+          launch session "Default Session"
 88+          set current_session to current session
 89+          tell current_session
 90+            write text "${command}"
 91           end tell
 92         end tell
 93       end tell
 94+EOF
 95+  }
 96+}
 97+
 98+function pfd() {
 99+  osascript 2>/dev/null <<EOF
100+    tell application "Finder"
101+      return POSIX path of (target of window 1 as alias)
102     end tell
103-end do_submenu
104+EOF