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