Here’s quick tip for anyone working with multiple projects using tools like git / grunt / gulp / vagrant on the command line. I find myself constantly switching between projects and it’s a little tedious to open up new tabs, changing directories and run the same commands over an over to setup my development ‘workspace’.
How I automate my development working environment:
I use a script that I’ve named start.sh, this sits in the base directory for each project. As I’ll be reusing this script I created a couple of variables for the directory names, this means it takes just seconds to set this up for a new project.
This is an example of the script, it does the following:
- Opens up a new tab in iTerm, then navigates to the git repo and runs git status
- Opens up another tab in iTerm, navigates to the theme dir and runs grunt (watch)
- Opens up another tab in iTerm to navigate to the theme dir and opens that directory in sublime
- Then finally runs a vagrant up to start the virtual machine for this project
* I’m sure this code could be improved but this is working well for me at the moment!
To automate this further – because why not ; ) ?
I’ve setup another alias up in my .zshrc file, this simply runs a script called start.sh. So all I now need to do is cd into the project directory and type ‘start’, the script runs and I can start working in a few seconds.