Skip to content

Instantly share code, notes, and snippets.

@isaacd9
Last active March 4, 2017 08:35
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 isaacd9/4802fc8b2ee69d7c443c583b00eaf5f6 to your computer and use it in GitHub Desktop.
Save isaacd9/4802fc8b2ee69d7c443c583b00eaf5f6 to your computer and use it in GitHub Desktop.
Pull a specific git ignore from Github with `gitignore`
function _gitignore(){
data=`curl -sf "https://raw.githubusercontent.com/github/gitignore/master/$1.gitignore"`;
if [ $? -eq 0 ]; then
echo "\n${data}" >> .gitignore;
else
echo "gitignore for $1 not found"
fi
}
function _gitignore_search(){
data=`curl -sf "https://api.github.com/repos/github/gitignore/contents"`;
if [ $? -eq 0 ]; then
echo $data | grep -i "\"name\": \"$1" | cut -c 14- | cut -d . -f 1;
else
echo "gitignore for $1 not found";
fi
}
function _gitignore_cat(){
data=`curl -sf "https://raw.githubusercontent.com/github/gitignore/master/$1.gitignore"`;
if [ $? -eq 0 ]; then
echo $data
else
echo "gitignore for $1 not found";
fi
}
alias gitignore='_gitignore'
alias gitignore-search='_gitignore_search'
alias gitignore-cat='_gitignore_cat'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment