Recently replaced the office computer from Windows to Mac, previously used Windows, under Windows to synchronize code to the remote development machine, Zend Studio has some built-in tools, but the Mac Zend Stduio without this tool. and sublime some synchronization plug-in is too difficult to use, so online search, to achieve synchronization.
1, in the background of the Mac run a script, the principle is to use the Mac's Fswatch command to detect changes in the directory files, and then through the rsync command to synchronize the changed files to the remote development machine, the code is as follows:
Pwd="/users/huangxuan01/desktop/baidu/adu/eap-dp-platform/fe/"CD $PWDfswatch $PWD| whileReadfile DoEcho "======"
#只需要相对路径sub_path=${file/${pwd}/}Echo$sub _path
#去掉第一个斜线sub_path=${sub_path/\//}Echo$sub _pathif[-F ${file}-o-d ${file} ] Thenrsync-ar ${sub_path} rsync://10.100.45.234:8667/wwwfiEcho "======" Done
2, on the remote development machine, run the rsync server. The configuration is as follows:
ID=Work Port=8667Address=127.0.0.1GID=Workusechroot=Nomax Connections=TenStrict Modes=Yeslogfile=/home/work/Rsync.logpidfile=/home/work/Rsync.pid[www]path=/home/work/baidu/adu/eap-dp-platform/fe/Comment=Analyseread only=falsehosts allow= *
Implementing code remote synchronization under Mac