Created
January 8, 2015 20:23
-
-
Save LogicalChaos/4e7a0fc331358370c3d1 to your computer and use it in GitHub Desktop.
Add to ~/.vagrant.d directory to put vagrant meta directories (hence VM) in a common directory based on the current directory name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
if !ARGV.find { |arg| /global/ =~ arg } and !ENV['VAGRANT_DOTFILE_PATH'] and File.exists?('.vagrant.keep') | |
if !ENV['VAGRANT_COMMON_DIRECTORY_ROOT'] | |
abort '.vagrant.keep file is present but VAGRANT_COMMON_DIRECTORY_ROOT is not set' | |
end | |
pn = Pathname::pwd | |
ENV['VAGRANT_DOTFILE_PATH'] = "#{ENV['VAGRANT_COMMON_DIRECTORY_ROOT']}/#{pn.basename}" | |
puts 'metadata directory: ' + ENV['VAGRANT_DOTFILE_PATH'] | |
if File.directory?('.vagrant') | |
#puts 'removing .vagrant directory' | |
FileUtils.rm_r('.vagrant') if File.directory?('.vagrant') | |
end | |
system 'vagrant ' + ARGV.join(' ') | |
abort | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment