Created
October 1, 2017 05:14
-
-
Save rskelley9/567252f545e7eb4bb97565e2c7795c43 to your computer and use it in GitHub Desktop.
I created this script to remove the hidden .DS_Store file from my projects and automatically initialize and update my .gitignore file to keep it untracked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -f "`find . -name .DS_Store`" ] ; then | |
if [ ! -f "`git rev-parse --is-inside-work-tree`" ] ; then | |
echo "no git repository found" | |
while true; do | |
read -p "Do you wish to initialize git repository in this folder $(echo $(pwd))?" yn | |
case $yn in | |
[Yy]* ) git init; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
fi | |
if[ ! -f "`find . -name .gitignore`" ] ; then | |
touch $(pwd)/.gitignore && echo "created .gitignore" | |
fi | |
echo "removing .DS_Store" | |
find . -name .DS_Store -print0 | xargs -0 git rm | |
git config --global core.excludesfile "$(pwd)/.gitignore" | |
echo .DS_Store >> ~/.gitignore && echo ".DS_Store added to .gitignore" | |
else | |
echo ".DS_Store not found." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I included this in a blog post.
https://ryankelley.tumblr.com/post/165922779758/a-script-to-remove-dsstore-from-your-project