class Threeman::Frontends::MacTerminal
Public Instance Methods
run_commands(commands)
click to toggle source
# File lib/threeman/frontends/mac_terminal.rb, line 12 def run_commands(commands) events = Appscript.app("System Events") terminal = Appscript.app("Terminal") terminal.activate terminal_controller = events.processes['Terminal'] commands.each_with_index do |command, index| if index == 0 terminal.do_script("") else sleep 0.3 # Terminal is slow and its scripting API is prone to misbehavior; wait for it to finish doing the thing we just did terminal_controller.keystroke("t", using: [:command_down]) terminal.do_script("", in: terminal.windows[0]) end sleep 0.3 terminal_controller.keystroke("cd #{Shellwords.escape command.workdir}\n") terminal_controller.keystroke(bash_cmd(command) + "\n") end end
Private Instance Methods
bash_cmd(command)
click to toggle source
# File lib/threeman/frontends/mac_terminal.rb, line 37 def bash_cmd(command) "bash -c #{Shellwords.escape bash_script(command)}" end