smithers
smithers

Reputation: 11

Set Vagrant VM name to be current working directory

I'd like to set the name of my Vagrant VM to be the current working directory. I'd like to do something like this but apparently it's not valid:

config.vm.provider "virtualbox" do |vb| vb.name = ENV[$PWD] end Suggestions are much appreciated Thanks.

Upvotes: 1

Views: 786

Answers (1)

Frederic Henri
Frederic Henri

Reputation: 53713

The following will work

  config.vm.provider :virtualbox do |vb|
      current_dir = File.basename(Dir.getwd)
      vb.name = current_dir
  end

Upvotes: 5

Related Questions