-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgenerate-gitignore.sh
More file actions
executable file
·32 lines (24 loc) · 970 Bytes
/
generate-gitignore.sh
File metadata and controls
executable file
·32 lines (24 loc) · 970 Bytes
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
#!/usr/bin/env bash
set -eu -o pipefail
ARCHIVE_NAME="gitignore_ocd.gz"
echo "[*] Fetching comprehensive gitignore lists from Toptal..."
echo ""
# Create the gitignore file with a header comment
{
echo "# Generated by OCD <https://github.com/nycksw/ocd>"
echo "# Data from <https://docs.gitignore.io/install/command-line>"
echo "# Generated on: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo ""
# Get all available lists
ALL_LISTS=$(curl -sL https://www.toptal.com/developers/gitignore/api/list \
| xargs | sed 's/ /,/g')
# Fetch and process the gitignore data; requires stripping some malformed comments.
curl -fsSL "https://www.toptal.com/developers/gitignore/api/$ALL_LISTS" \
| sed 's/^ *[\*\\\/]*//g' \
| cat -s
} | gzip -9 -f > $ARCHIVE_NAME
file -i $ARCHIVE_NAME
ls -lh $ARCHIVE_NAME
echo ""
echo "[*] Successfully created gitignore_ocd.gz"
echo "This file can now be committed to the repo and will be fetched during installation."