Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Created March 21, 2016 11:03
Show Gist options
  • Save ahmadawais/39054683f6c336ec9980 to your computer and use it in GitHub Desktop.
Save ahmadawais/39054683f6c336ec9980 to your computer and use it in GitHub Desktop.
ZSH: WP: ZIP: Zip the current folder and exclude folders and files that are not needed as per Theme Check.
# Zip the current folder and exclude
# folders and files that are not needed
# as per Theme Check.
#
# Usage: wpzip zipname
# Link: http://askubuntu.com/a/28482/521222
function wpzip(){
echo "${whitef}———————————————————${reset}"
zip_name=$1 # $1 is agrument 1
# exclude more files (does not work for folders)
more_exclude_file=${@:2} # ${@:2} is everything from argument 2 to end
echo "${whiteb} ${blackf}0. Deleting the old "$zip_name".zip file if present...${reset}"
rm $zip_name".zip"
echo "${whiteb} ${blackf}1. Zipping the current folder as "$zip_name".zip...${reset}"
# Using noglob to avoid ZSH to trip over *, can also use back slash \
noglob zip -r $zip_name.zip . -x *.git* *node_modules* *.zip *.DS_Store $more_exclude_file
echo "${greenb} ${blackf}3. "$zip_name".zip is ready! 💯 ${reset}"
echo "${whitef}———————————————————${reset}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment