Skip to content

Instantly share code, notes, and snippets.

@burke
Last active June 20, 2016 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burke/7b42db0b6cc0828d462f79b4a5108cdf to your computer and use it in GitHub Desktop.
Save burke/7b42db0b6cc0828d462f79b4a5108cdf to your computer and use it in GitHub Desktop.
-- compiled from https://github.com/janko-m/vim-test/tree/master/bin
on run argv
set command to argv
-- without doing this as a var, it will launch iterm2
set iterm to "iTerm2"
if application iterm is running then
tell application "iTerm"
set _window to (current window)
if _window is equal to missing value then
create window with default profile
end if
tell current window
tell current session
write text (item 1 of argv)
end tell
end tell
end tell
else
tell application "Terminal"
if (count of windows) is 0 then
do script command
else
if window 1 is busy then
activate
tell application "System Events" to keystroke "t" using {command down}
repeat while contents of selected tab of window 1 starts with linefeed
delay 0.01
end repeat
do script command in selected tab of window 1
else
do script command in window 1
end if
end if
activate
end tell
delay 0.02
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment