blob: ee0f4ec310770e477dd67be5c28d9372802a90fa (
plain)
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
|
#!/usr/bin/env zsh
emulate -L zsh
if [[ ${1} == '--help' || ${1} == '-h' || ${1} == '' ]]; then
echo "Usage: ${0} [--help|-h] [reference]"
return 0
fi
if [[ -f .gitignore ]]; then
echo '.gitignore already exists'
return 1
fi
local TEMP="$(mktemp)"
if curl --fail --silent "https://raw.githubusercontent.com/github/gitignore/main/${1}.gitignore" > "${TEMP}"; then
mv "${TEMP}" ".gitignore"
elif curl --fail --silent "https://raw.githubusercontent.com/github/gitignore/main/${(C)1}.gitignore" > "${TEMP}"; then
mv "${TEMP}" ".gitignore"
else
echo "Could not get ${1}"
return 2
fi
# Uncomment things I generally prefer uncommented
sed -i -E 's% *# *(.idea/|poetry.lock|Pipfile.lock|.python-version|pdm.lock)%\1%g' ".gitignore"
echo ".gitignore created"
|