summaryrefslogtreecommitdiff
path: root/vim/bundle/slimv/ftplugin/iterm.applescript
diff options
context:
space:
mode:
authorNick Shipp <nick@shipp.ninja>2017-05-07 09:04:01 -0400
committerNick Shipp <nick@shipp.ninja>2017-05-07 09:04:01 -0400
commitc012f55efda29f09179e921cf148d79deb57616e (patch)
treeff0ad37f22622d51194cab192a2aa4b0106d7ad0 /vim/bundle/slimv/ftplugin/iterm.applescript
parent4ca8f6608883d230131f8a9e8b6d6c091c516049 (diff)
Much maturering of vim configs
Diffstat (limited to 'vim/bundle/slimv/ftplugin/iterm.applescript')
-rwxr-xr-xvim/bundle/slimv/ftplugin/iterm.applescript66
1 files changed, 66 insertions, 0 deletions
diff --git a/vim/bundle/slimv/ftplugin/iterm.applescript b/vim/bundle/slimv/ftplugin/iterm.applescript
new file mode 100755
index 0000000..28923d8
--- /dev/null
+++ b/vim/bundle/slimv/ftplugin/iterm.applescript
@@ -0,0 +1,66 @@
+#! /usr/bin/osascript
+-- joinList from Geert Vanderkelen @ bit.ly/1gRPYbH
+-- toDo push new terminal to background after creation
+to joinList(aList, delimiter)
+ set retVal to ""
+ set prevDelimiter to AppleScript's text item delimiters
+ set AppleScript's text item delimiters to delimiter
+ set retVal to aList as string
+ set AppleScript's text item delimiters to prevDelimiter
+ return retVal
+end joinList
+
+-- theSplit from iTerm version check example @ https://goo.gl/dSbQYU
+on theSplit(theString, theDelimiter)
+ set oldDelimiters to AppleScript's text item delimiters
+ set AppleScript's text item delimiters to theDelimiter
+ set theArray to every text item of theString
+ set AppleScript's text item delimiters to oldDelimiters
+ return theArray
+end theSplit
+
+-- IsModernVersion from iTerm version check example @ https://goo.gl/dSbQYU
+on IsModernVersion(version)
+ set myArray to my theSplit(version, ".")
+ set major to item 1 of myArray
+ set minor to item 2 of myArray
+ set veryMinor to item 3 of myArray
+
+ if major < 2 then
+ return false
+ end if
+ if major > 2 then
+ return true
+ end if
+ if minor < 9 then
+ return false
+ end if
+ if minor > 9 then
+ return true
+ end if
+ if veryMinor < 20140903 then
+ return false
+ end if
+ return true
+end IsModernVersion
+
+on run arg
+ set thecommand to joinList(arg, " ")
+ tell application "iTerm"
+ activate
+ if my IsModernVersion(version) then
+ set myterm to (create window with default profile)
+ set mysession to current session of myterm
+ else
+ set myterm to (make new teminal)
+ tell myterm
+ set mysession to (launch session "Default")
+ end tell
+ end if
+ tell myterm
+ tell mysession
+ write text thecommand
+ end tell
+ end tell
+ end tell
+end run