I'm not an expert at shell scripting, but I wrote this little ditty over a year ago and I use it ALL the time. It really makes my life easier. If you work locally with code that needs to be tested on a remote server, you change multiple files at a time, and/or you're using FTP to transfer these files, then this might be a great solution for you. It's a super simple concept, just a nested switch statement used in combination with find, grep, and rsync. However, the uses are so convenient for me that if you were to scroll through my history of my cli commands 70%+- of them would reference this script. I'm posting about it because I want to see if anyone has suggestions for other useful Web Developer functions to add to it.
Here's how I use it. I save the script as /usr/local/bin/my, then just call it like so (example result included):
user@host:~# my find 'some_function_name'
./some/folder/File.php:193: protected function some_function_name($arg1){
The 'sync' option just rsync's the current working directory to the specific server, so be mindful of your working directory!
user@host:~# my sync dev Number of files: 208 Number of files transferred: 173 Total file size: 844041 bytes Total transferred file size: 844041 bytes Literal data: 7851 bytes Matched data: 836190 bytes File list size: 4577 File list generation time: 0.009 seconds File list transfer time: 0.000 seconds Total bytes sent: 15799 Total bytes received: 11572 sent 15799 bytes received 11572 bytes 7820.29 bytes/sec total size is 844041 speedup is 30.84
And here's the code. Like I said, very very simple. If you're a *nix guru you'd probably snort your nose at it, but if you're just an average developer with budding skills, this might change your work-flow quite a bit. Hope someone finds it useful :) If you have suggestions for additional functionality please post them!
case $1 in
find)
find . \( -name "*.php" -o -name "*.py" \) -exec grep -Hn $2 {} \;
;;
findall)
find . -exec grep -Hn $2 {} \;
;;
sync)
case $2 in
dev)
rsync -rz --stats . dev.yourserver.com:/path/to/directory
;;
staging)
rsync -rz --stats . staging.yourserver.com:/path/to/directory
;;
esac
;;
*)
echo "That option is not recognized"
;;
esac
Corwin dismounts Julian and takes him prisoner.
Posted by: Juicy Couture Handbags | 11/11/2010 at 07:09 PM
*Oh I hope you all have a blessed day
Posted by: buy from taobao | 11/12/2010 at 11:46 PM
*A good heart, a pair of industrious hand.
Posted by: air Jordan | 12/08/2010 at 12:50 AM
Um...like the style of your writing.*_*
Posted by: Taobao buy | 01/14/2011 at 12:31 AM
I believe it is a great contribution and someone might find it useful in their work. It is the thought that counts and the information is being posted in case it will help someone do their work faster. Thank you for doing this and thinking of others around you.
Posted by: Jordan 1 | 01/15/2011 at 11:56 PM
*Farmers are busy in this season. Autumn Maple leaves redden, it's very beautiful, but other leaves are yellow.
Posted by: Cheap Coach Bags | 01/17/2011 at 12:18 AM
If you want to sing a song. Ensure it is easy to previous your whole life much time. Will not worry that it is not very good adequate For any one else to know.Just sing, sing a song!
Posted by: MBT Wingu | 02/25/2011 at 05:00 PM
It is often inferred that you just lack self-confidence within a victory through your rivals on the certainty that you happen to be irritable alongside them.
Posted by: Supra TK Society | 03/06/2011 at 04:30 PM