Create aliases on host while roaming using roaming triggers

Hope someone can help me here.

I want to create aliases on my local machine (host) at startup vagrant up

. Through my search for a vagrant launch command on the host, I stumbled upon a vagrant-triggers

plugin. From the surface, it appears to do exactly what I want (executing a script / command on the host machine during the vagrant preparation process), however I was unable to get it to work successfully.

Below is a sample code. I am not getting any errors, but aliases are not available on the host.

Vagrant.configure("2") do |config|
  # Your existing Vagrant configuration
  ...

  # start vagrant-triggers example code
  {
    :up => [
      'alias runscript="$(PWD)/script"',
      'alias runscript2="$(PWD)/script2"'
    ],
    [:halt, :destroy] => [
      'unalias runscript',
      'unalias runscript2'
    ]
  }.each do |trigger, commands|
    config.trigger.after trigger, :stdout => true do
      commands.each do |command|
        run command
      end
    end
  end

  ...
end

      

+3


source to share





All Articles