Skip to content

Instantly share code, notes, and snippets.

@t9md
Created November 5, 2010 02:48
Show Gist options
  • Save t9md/663578 to your computer and use it in GitHub Desktop.
Save t9md/663578 to your computer and use it in GitHub Desktop.
execute shell command on iTerm window from MacVim via rb-appscript
ruby << ENDRUBY
require 'rubygems'
require 'appscript'
include Appscript
class ITerm
class << self
def activate;
@iterm ||= app('iTerm')
end
def write(cmd)
@iterm.current_terminal.sessions.write(:text => cmd)
end
end
end
class MacVim
class << self
def activate
@app ||= app('MacVim')
@app.windows.first.activate
end
end
end
ENDRUBY
fun! ITermWrite(cmd)
ruby << ENDRUBY
cmd = VIM::evaluate('a:cmd')
ITerm.activate
ITerm.write(cmd)
MacVim.activate
ENDRUBY
endfun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment