class ITermCLI::Terminal::SendKeys

Constants

SOURCE

Public Instance Methods

call(keys, options = {}) click to toggle source
# File lib/iterm_cli/terminal/send_keys.rb, line 22
def call(keys, options = {})
  options = {target: nil}.merge(options)
  target = options[: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