class Sesh::SshControl
Public Class Methods
new(tmux_control, options={})
click to toggle source
# File lib/sesh/ssh_control.rb, line 5 def initialize(tmux_control, options={}) @tmux_control = tmux_control @project = @tmux_control.project @options = DEFAULT_OPTIONS[:ssh].merge(options) end
Public Instance Methods
connection_command(addr=nil)
click to toggle source
# File lib/sesh/ssh_control.rb, line 11 def connection_command(addr=nil) addr ||= @options[:remote_addr] tmux_cmd = @tmux_control.connection_command return tmux_cmd if addr == @options[:local_addr] "ssh #{addr} -t '#{tmux_cmd}'" end
enslave_peer!()
click to toggle source
# File lib/sesh/ssh_control.rb, line 42 def enslave_peer! cmd = %Q[ssh #{@options[:remote_addr]} -t "sesh connect ] cmd << %Q[-p #{@project} -R #{@options[:local_addr]}] cmd << ' -N' if @options[:connect_in_new_window] cmd << ' -F' if @options[:connect_fullscreen] cmd << '"' system cmd end
enter_slave_mode_command(addr=nil)
click to toggle source
# File lib/sesh/ssh_control.rb, line 18 def enter_slave_mode_command(addr=nil) @term_app ||= Inferences.infer_terminal_app case @term_app when 'iTerm' tell_term_app = %Q[tell application "#{@term_app}"] tell_term_process = %Q[tell application "System Events" to tell process "#{@term_app}"] cmd = %Q[osascript -e '#{tell_term_app} to activate'] if @options[:connect_in_new_window] cmd += %Q[ -e '#{tell_term_process} to keystroke \"n\" using command down'] cmd += %Q[ -e 'delay 1'] end cmd += %Q[ -e "#{tell_term_app.gsub('"', '\\"')} to tell session -1] << %Q[ of current terminal to write text \\"#{connection_command(addr)}\\""] if @options[:connect_fullscreen] # TODO: come up with a non-toggling way to ensure fullscreen cmd += %Q[ -e '#{tell_term_process} to keystroke return using command down'] end Sesh.format_command cmd when 'Terminal' then Sesh.format_command connection_command(addr) end end