Have one project folder and copy to the right place

Hello, I have this idea to make one single project folder.

~/projects/
  0003 - Something project/
  0002 - awesome project/  
  0001 - Hello world/

Problem I’m having is that I develop in Wordpress and the project folder need to be in a specific folder in the Wordpress folder structure.

Do anyone know how to maybe sync the project folder with an other folder somewhere else?

I use a Mac.

Perhaps with a symbolic link?

Efter spending hour to figure this out I found a solution. Thought I share the solution if somebody have similar problem. Or if you know a better solution… :smiley:

So there a two parts:

  • Sync the folders
  • Watch the source folder for changes

sync the folders

After trying to get “symbolic link” to work with Vagrant, I decided to use rsync instead.
Rsync works in the terminal and is easy to use.

The command:

rsync options source destination

My command that exclude files and delete files in target dir if I delete files in source (–delete):

rsync -avzi --delete --exclude '.git' --exclude 'node_modules' --exclude '.DS_Store' ~/drive/projects/test-folder ~/Documents/vagrant-local/www/crazynomads/htdocs/wp-content/themes

Watch the source folder for changes

For this I use fswatch. This use a simple line that can be configured to run a shell file when something have been change in a folder.

fswatch -o path | xargs -n1 program

This is how my command looks like:

fswatch -o ~/drive/projects | xargs -n1 sh sync.sh
  • What folder the watch - ~/drive/projects
  • What program to run - sync.sh

sync.sh contains the rsync command.

Now I can have a folder with all my project and sync them with other places like Wordpress theme folders etc…