Hoping someone can help me out here.

I am wanting to create aliases on my local machine (host) when running vagrant up. Through my search for vagrant run command on host, I came across the 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 provisioning process), however I have not been able to get it working successfully.

Below is my example code. I don't receive any errors, but the 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


The commands are executed in a subshell of the vagrant process, and aliases are only available for that subshell, not for any of the parent processes. So you would need to for example write helper scripts to a directory that you put in the PATH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.