Class: ITermCLI::Terminal::SendKeys
- Defined in:
- lib/iterm_cli/terminal/send_keys.rb
Constant Summary collapse
- SOURCE =
<<-JS.freeze function run(argv) { var options = JSON.parse(argv[0]); var iTerm = Application("iTerm2"); var window = iTerm.currentWindow(); var i, session; for (i = 0; i < window.tabs.length; i++) { session = window.tabs[i].currentSession(); if (session.name() === options.target) { session.write({text: options.text}); } } return; } JS
Instance Method Summary collapse
Methods inherited from Function
Instance Method Details
#call(keys, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/iterm_cli/terminal/send_keys.rb', line 22 def call(keys, = {}) = {target: nil}.merge() target = [:target] text = keys.map {|t| case t when /\AC-(.)$\z/ ($1.ord & 0b00011111).chr when "Enter" "\n" else t end }.join(" ") osascript(SOURCE, target: target, text: text) end |