Easy One Click Laravel Homestead Shortcut (Windows)

If you are like me and work a lot in Laravel Homestead on your Windows computer, would it not be lovely to be able to fire that virtual environment up with one button? I used to have to open my command prompt, change directory and then write vagrant up. What makes matters worse is that you have to wait for Vagrant to fire up.


We should first download and install the required programs. They will make your life as a developer easier anyways. Skip this step if you have already installed the programs below.

  1. Vagrant
  2. Laravel Homestead
  3. Git for Windows

Let's Get Started

Step 1. Create a bash file

For simplicity, we will call this file homestead.sh. I have saved it in my user folder at C:\Users\Bryse\.

Place the following contents into your newly created homestead.sh.

cd /c/Homestead
echo "Starting Vagrant"
vagrant up
vagrant ssh
echo "Suspending Vagrant"
vagrant suspend

This will change your active directory to whatever path after the first cd command. I have Homestead installed into a folder at the path C:\Homestead. In the bash command C:\ becomes /c/. It will then run vagrant up and vagrant ssh so that you can get started right away.

It is always recommended to suspend Vagrant when finished. If you are done with your virtual enviroment, you can type exit. This will make you logout from the SSH session and automatically suspend Vagrant for you.

Step 2. Create the shortcut

This is the tricky part. We want our shortcut to open Git Bash and then run the homestead.sh file that we made.

Go ahead and create a new shortcut anywhere on your computer. Set the target to the following: C:\Windows\System32\cmd.exe /c ""C:\Program Files\Git\bin\sh.exe" --login -i -- "C:\Users\Bryse\homestead.sh""

Please note that you will have to change the directory paths if they are different for your system.

I will break down what is going on here.

  1. C:\Windows\System32\cmd.exe will tell the shortcut to launch a new command prompt.
  2. ""C:\Program Files\Git\bin\sh.exe" --login -i" tells the command prompt to run this program.
  3. --login -i will log you in the for git bash Linux subsystem. Git bash does this automatically when opening a new prompt.
  4. -- "C:\Users\Bryse\homestead.sh" comes last. This will tell the new git bash prompt to run our bash script that we made earlier.

Step 3. Give the shortcut an icon

I like to keep my system looking nice, so I found a cool icon to use for my new shortcut.

You can use ConvertIco.com to convert a .png to a .ico. Right click your shortcut and go to properties. You can then set your shortcut's icon to the icon we just converted.

I have pinned my shortcuts to my Task Bar on Windows 10.

Step 4. Get coding!

With our fancy new shortcut, you can easily start Laravel Homestead with a click of a button.

Happy coding!

Posted: Tuesday, October 04, 2016


Leave a Comment