Skip to content

Instantly share code, notes, and snippets.

@matiassingers
Last active August 29, 2015 14:05
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 matiassingers/8248b4345fb56b8a08da to your computer and use it in GitHub Desktop.
Save matiassingers/8248b4345fb56b8a08da to your computer and use it in GitHub Desktop.
# .gitignore function
# Improved a little upon the original by kqr - https://github.com/kqr/gists/blob/51f63900924e483888cdd7f777177e804bfb0cca/utils/gi
function gi() {
result=$(curl "http://www.gitignore.io/api/$1" 2>/dev/null)
if [[ $result =~ ERROR ]]; then
echo "Query '$1' has no match. See a list of possible queries with 'gi list'"
elif [[ $1 = list ]]; then
echo "$result"
else
if [[ -f .gitignore ]]; then
result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"`
echo ".gitignore already exists, appending"
echo "$result" >> .gitignore
else
echo "$result" > .gitignore
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment