Skip to content

Instantly share code, notes, and snippets.

@RickMoynihan
Last active December 10, 2015 19:48
Show Gist options
  • Select an option

  • Save RickMoynihan/4483756 to your computer and use it in GitHub Desktop.

Select an option

Save RickMoynihan/4483756 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: Rick Moynihan
# (c) 2013 Stardotstar Ltd
#
# Script to aid copying .gitignore files from the github gitignore project.
#
# Usage:
#
# 1) $ git clone https://github.com/github/gitignore.git
#
# 2) Edit this script and change GITIGNORE_PROJECT_PATH to the path of the repo you downloaded.
#
# 3) Copy script to your path and chmod +x make-gitignore
#
# 4) Run make-gitignore [IGNORE-FILES]
#
#
GITIGNORE_PROJECT_PATH=~/repos/gitignore
if [ "$#" -eq 0 ];then
echo "Usage: $(basename $0) IGNORE-FILE"
echo
declare PROG_IGNORES=$(ls $GITIGNORE_PROJECT_PATH | sed -E 's/\.gitignore|\.\/Global:|LICENSE|README\.md|\.://g' | tr '\n' ' ')
declare GLOB_IGNORES=$(ls $GITIGNORE_PROJECT_PATH/Global | sed -E 's/(.*)\.gitignore|LICENSE|README\.md|\.:/Global\/\1/g' | tr '\n' ' ')
echo "Where IGNORE-FILE is one of: $PROG_IGNORES$GLOB_IGNORES"
else
for i in $*
do
echo $i
cat $GITIGNORE_PROJECT_PATH/$i.gitignore >> .gitignore
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment