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.
For simplicity, we will call this file
homestead.sh. I have saved it in my user folder at
Place the following contents into your newly created
cd /c/Homestead echo "Starting Vagrant" vagrant up vagrant ssh echo "Suspending Vagrant" vagrant suspend ts
This will change your active directory to whatever path after the first
I have Homestead installed into a folder at the path
C:\Homestead. In the bash command
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.
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.
C:\Windows\System32\cmd.exewill tell the shortcut to launch a new command prompt.
""C:\Program Files\Git\bin\sh.exe" --login -i"tells the command prompt to run this program.
--login -iwill log you in the for git bash Linux subsystem. Git bash does this automatically when opening a new prompt.
-- "C:\Users\Bryse\homestead.sh"comes last. This will tell the new git bash prompt to run our bash script that we made earlier.
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.
With our fancy new shortcut, you can easily start Laravel Homestead with a click of a button.