Automatically switch folders on vagrant ssh

Posted by Andy Huggins on August 02, 2016

This isn't the biggest deal, it's just a little convenience that makes working with your vm a little easier/nicer.

So what do we need to do?

First, you will need to

vagrant ssh

Once in your vm, you should be able to do a `ls -a` command, which should list all the files, including the hidden ones. We are looking for either a `.bashrc` or a `.bash_profile` file. You will want to edit this using Vim. See Laracasts Vim Mastery for info on how to use Vim.

We are going to add a line to the `.bashrc` file (or .bash_profile if that is what you have), we want to add:

cd ../../var/www/
This path should be customized to the vm you are using, but it most likely is something like above.

Save the file. Now you should be able to `exit` from the vm, then `vagrant ssh` back into the vm and be in the folder where your code lives.

These quick little helpers help to remove just a few steps from working on something, this allows you to focus on what is important, which is what we should all be focusing on.