Vagrant Tips for Windows

| Comments

Here are some tips to improve the day-to-day Vagrant tasks on a Windows machine.

  • Saving diskspace
  • Using a better terminal
  • Using a better text editor

Moving the Vagrant home folder to another disk

Vagrant puts its boxes by default in your home directory (~/.vagrant.d). But it can fill up diskspace really quickly. Especially if you are creating Windows VM’s. So what you want to do is edit the VAGRANT_HOME variable and give it a value which suits your needs (to a cheaper or bigger disk). Here’s the Powershell command:

[Environment]::SetEnvironmentVariable("VAGRANT_HOME", "D:\vagrant_home", "User")

Using Cmder as an alternative terminal

OK. Microsoft is trying but they will never succeed to overrule the power of a Linux terminal and commandline. But with Cmder you can simulate the Linux experience rather decently. And if you decide to use the slightly bigger msysgit version of Cmder, you will have all Unix commands ready in PATH so that you can git init or cat instantly on every machine. Yay! git

Using Sublime to edit the Vagrantfile

I love Sublime as a text editor. Install it with Chocolatey and then add subl.exe command to your path. Here’s (again) a way to do that with Powershell:

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";%ProgramFiles%\Sublime Text 3", [System.EnvironmentVariableTarget]::Machine)

Now you can go to Cmder, cd to you vagrant machine folder and type:

subl Vagrantfile

Now you can work from the terminal with Sublime instead of juggling with Notepad instances.

Add Powershell syntax colors to Sublime text

In Sublime Text:

  • Press Ctrl + Shift + P
  • Select ‘Install Package’
  • Select ‘PowerShell’