250bee9cda1436c9f9ae900eaf540c82642c9031

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #206 from sorin-ionescu/plugin-osx

Vastly improved Mac OS X plugin

Diff

This diff is truncated to protect this page.

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