Skip to content

Instantly share code, notes, and snippets.

@tmr111116
Created June 2, 2015 10:17
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 tmr111116/e8f7aa3e512d8e5d1d1d to your computer and use it in GitHub Desktop.
Save tmr111116/e8f7aa3e512d8e5d1d1d to your computer and use it in GitHub Desktop.
pull したタイミングで .DS_Store だけが含まれるフォルダを削除する git hook
#!/bin/sh
# pull したタイミングで .DS_Store を消して、 .DS_Store だけが含まれるフォルダを削除する。
#
# まず .DS_Store を削除してから、 .DS_Store が入っていたディレクトリを rmdir する。
# rmdir は空の場合しか削除しないので、中身が入っている場合はそのまま。 grep で不要なエラーメッセージを無視。
find . -name .DS_Store -exec rm {} \; -exec sh -c 'rmdir `dirname {}` 2>&1 | grep -E -v "rmdir:.+: Directory not empty"' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment