Class: VagrantPlugins::Tmuxme::TmuxmeCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-tmuxme/tmuxme_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-tmuxme/tmuxme_command.rb', line 6

def execute
  options = {}

  opts = OptionParser.new do |opt|
    opt.banner = "Usage: vagrant tmuxme [username]"
  end

  argv = parse_options(opts)

  with_target_vms("default") do |vm|
    raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
    raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
  end

  with_target_vms("default") do |vm|
    vm.guest.capability(:ensure_tmux, @env)
    vm.guest.capability(:ensure_tmuxme, @env)
    @env.ui.info "Starting pair session with #{argv.join(" ")}"
    vm.action(:ssh, ssh_opts: { extra_args: ["-t", ". /etc/profile; . ~/.profile; tmuxme #{argv.join(" ")}"], subprocess: true })
  end
end