One-line bash script to create WordPress plugin zip from plugin directory

How I make a zip and ignore .idea, .git and other directories as defined in the .gitignore file

This should not be done on a production site since a zip of the plugin will be publicly available and could expose sensitive information about your WordPress site.

cd into the plugin’s directory

cd wp-content/plugins/PLUGIN_NAME

This command will create a zip in the parent directory (wp-content/plugins)

echo ${PWD##*/} | xargs -I % sh -c 'cd .. ; zip -r "%.zip" % -x "*.git*" @"%/.gitignore"'