If you're trying to zip files on Mac OS but keep getting stuck with the hidden files like .DS_Store and __MACOSX then there's a simple command line solution for you. And yes, that means you can't use the built-in Mac graphical tools, you have to use the command line. Thankfully, it's simple:
zip -x *.DS_Store -x *__MACOSX* -x *.AppleDouble* -r myfile.zip MyFolder
All this said is the “-x” means exclude and the “-r” means recursive (since in this case we're compressing a folder).
To make sure super easy in the future let's add this to an alias in our shell of choice. I use ZSH so for me I edited my .zshrc file, though you are probably using the default BASH shell so you'll want to edit (or create if it's not there) .bashrc file and add the following in there:
alias zip="zip -x '*.DS_Store' -x '*__MACOSX*' -x '*.AppleDouble*'"
I got this idea from the Reddit post below, but it wasn't correct anymore as we need to add the single quotes around the exclude arguments. So now all I have to do is type something like the following below and it'll automagically exclude the unwanted Mac files:
zip -r super-secret-code.zip Latest-Project-Folder