Skip to content

Commit a6021b7

Browse files
committed
extensions: add ignore-all
1 parent 5c583a6 commit a6021b7

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

bin/git-ignore-add

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2015-2016
4+
# Author: Victor Arribas <[email protected]>
5+
# License: GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
6+
#
7+
# Usage:
8+
# git ignore-add C++
9+
10+
set -e
11+
12+
usage(){
13+
cat<<EOF
14+
git-ignore-add
15+
Copyright (c) 2015-2016, Victor Arribas <[email protected]>
16+
17+
Append complex ignore rules to .gitignore by using GitHub's predefined
18+
ignore files.
19+
You can see a list of common ignore files at:
20+
https://github.com/github/gitignore
21+
22+
Usage: git ignore-add <template>
23+
Examples:
24+
git ignore-add C++
25+
git ignore-add Global/Eclipse
26+
27+
EOF
28+
}
29+
30+
GitHub_Database=https://raw.githubusercontent.com/github/gitignore/master
31+
32+
get_from_internet(){
33+
if wget -q --spider $1; then
34+
echo "# $1"
35+
wget -q -O- $1
36+
echo
37+
echo
38+
else
39+
echo "Error: Requested file do not exists (file=$1)">&2
40+
exit 1
41+
fi
42+
}
43+
44+
main(){
45+
if [ -z "$1" ] || [ "--help" = "$1" ]; then
46+
usage
47+
exit 1
48+
fi
49+
50+
filename=${GitHub_Database}/${1}.gitignore
51+
get_from_internet "$filename" >> .gitignore
52+
}
53+
54+
55+
main $@

0 commit comments

Comments
 (0)