Method: Pssh::Pty#set_command

Defined in:
lib/pssh/pty.rb

#set_commandObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/pssh/pty.rb', line 77

def set_command
  case Pssh.command.to_sym
  when :tmux
    if ENV['TMUX']
      @path = ENV['TMUX'].split(',').first
      @existing_socket = true
      @command = "tmux -S #{@path} attach"
    else
      @path = "/tmp/#{Pssh.default_socket_path}"
      @command = "tmux -S #{@path} new"
    end
    @attach_cmd = "tmux -S #{@path} attach"
  when :screen
    if ENV['STY']
      @path = ENV['STY']
      @existing_socket = true
      @command = "screen -S #{@path} -X multiuser on && screen -x #{@path}"
    else
      @path = Pssh.default_socket_path
      @command = "screen -S #{@path}"
      puts @command
    end
    @attach_cmd = "screen -x #{@path}"
  else
    @path = nil
    @command = ENV['SHELL'] || (`which zsh` && 'zsh') || (`which sh` && 'sh') || 'bash'
  end
end