Skip to content

Instantly share code, notes, and snippets.

@arrowtype
Created June 7, 2023 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arrowtype/b585c4b1536a4fece9bd50802da96039 to your computer and use it in GitHub Desktop.
Save arrowtype/b585c4b1536a4fece9bd50802da96039 to your computer and use it in GitHub Desktop.
A shell function to zip folders, excluding macOS metadata files. Add to your .bash_profile (or similar) to have a "zipit" command.
function zipit {
currentDir=$(pwd) # get current dir so you can return later
cd $(dirname $1) # change to target’s dir (works better for zip)
target=$(basename $1) # get target’s name
zip -r $target.zip $target -x '*/.DS_Store' # make a zip of the target, excluding macOS metadata
echo "zip made of " $1 # announce completion
cd $currentDir # return to where you were
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment