Shell scripts for easier website scaffolding part 2

Another bit of Bash script fun for prepping a directory or file for deployment.
echo "Which directory or file do you want to deploy?"
read sourcedirectory
echo "ZIP'ing up directory/file"
zip -r --exclude=\.git --exclude=\node_modules --exclude=\bower_components --exclude=\.npm --exclude=\.idea --exclude=\.hg $sourcedirectory $sourcedirectory
echo "Syncing ZIP'ed folder/file to Deploy directory"
rsync -r --progress $ ~/Deploy
echo "Done! You can find your deployment package $ here: ~/Deploy (type cd ~/Deploy to go there)

So some explanations for those not too familiar with shell scripts – this function goes in your bash profile (.bash_profile in your user account, if it doesn’t exist you can create it). read is a command that asks for user input – we’re asking the user to tell us which file or directory they want us to run on. Then we zip up the file/directory making sure to exclude things we don’t want deployed to production and save the ZIP’ed file name the same as the directory we’re “deploying”. And then we use rsync to copy the ZIP archive to our deploy folder.

You can totally tweak this so that instead of zipping the directory or files up, it could just rsync the directory or files to a remote directory – the skies the limit (or really your user privileges).