|
|
@ -10,14 +10,20 @@ class TerminalSession
|
|
|
|
def run_command(command)
|
|
|
|
def run_command(command)
|
|
|
|
send_string(command)
|
|
|
|
send_string(command)
|
|
|
|
send_keys('enter')
|
|
|
|
send_keys('enter')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def send_string(str)
|
|
|
|
def send_string(str)
|
|
|
|
tmux_command("send-keys -t 0 -l '#{str.gsub("'", "\\'")}'")
|
|
|
|
tmux_command("send-keys -t 0 -l '#{str.gsub("'", "\\'")}'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def send_keys(*keys)
|
|
|
|
def send_keys(*keys)
|
|
|
|
tmux_command("send-keys -t 0 #{keys.join(' ')}")
|
|
|
|
tmux_command("send-keys -t 0 #{keys.join(' ')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def content(esc_seqs: false)
|
|
|
|
def content(esc_seqs: false)
|
|
|
@ -29,6 +35,8 @@ class TerminalSession
|
|
|
|
def clear
|
|
|
|
def clear
|
|
|
|
send_keys('C-l')
|
|
|
|
send_keys('C-l')
|
|
|
|
sleep(0.1) until content == ''
|
|
|
|
sleep(0.1) until content == ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
def destroy
|
|
|
|