Last active
March 4, 2017 08:35
-
-
Save isaacd9/4802fc8b2ee69d7c443c583b00eaf5f6 to your computer and use it in GitHub Desktop.
Pull a specific git ignore from Github with `gitignore`
This file contains 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
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