Clean up TerminalSession constructor a bit

This commit is contained in:
Eric Freese 2017-01-29 10:43:00 -07:00
parent 51e8755634
commit 98f926d53d

View file

@ -3,8 +3,17 @@ require 'securerandom'
class TerminalSession class TerminalSession
ZSH_BIN = ENV['TEST_ZSH_BIN'] || 'zsh' ZSH_BIN = ENV['TEST_ZSH_BIN'] || 'zsh'
def initialize(width: 80, height: 24, prompt: '', term: 'xterm-256color') def initialize(opts = {})
tmux_command("new-session -d -x #{width} -y #{height} 'PS1=#{prompt} TERM=#{term} #{ZSH_BIN} -f'") opts = {
width: 80,
height: 24,
prompt: '',
term: 'xterm-256color',
zsh_bin: ZSH_BIN
}.merge(opts)
cmd="PS1=#{opts[:prompt]} TERM=#{opts[:term]} #{ZSH_BIN} -f"
tmux_command("new-session -d -x #{opts[:width]} -y #{opts[:height]} '#{cmd}'")
end end
def run_command(command) def run_command(command)