Initial commit

This commit is contained in:
niku 2023-07-11 22:41:01 +02:00
parent c0536948b7
commit 0430546934
3 changed files with 45 additions and 1 deletions

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
install:
chmod +x gitigrab
cp gitigrab ${HOME}/.local/bin/gitigrab
uninstall:
rm ${HOME}/.local/bin/gitigrab

View File

@ -1,3 +1,15 @@
# gitigrab
Quickly add .gitignore files to your projects.
Helps you quickly add a gitignore file to your projects.
## Usage
```sh
$ gitigrab
# Usage: gitigrab <template>
# Example 1: Add a Go gitignore file named `Go.gitignore`
$ gitigrab go > Go.gitignore
# Example 2: Add a Python gitignore file named `.gitignore`
$ gitigrab python
```

26
gitigrab Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -eo pipefail
if [ -z "$1" ]; then
echo "Usage: $(basename $0) <template>"
exit 0
fi
DATA_DIR="$HOME/.local/share/gitigrab"
if [ ! -d "$DATA_DIR" ]; then
git clone https://github.com/github/gitignore.git $DATA_DIR
fi
CURRENT_DIR=$(pwd)
cd $DATA_DIR
git pull -q
TEMPLATE=$(find . -type f -name "*.gitignore" | grep -iF $1 | head -n 1)
if [ -t 1 ]; then
cp $TEMPLATE $CURRENT_DIR/.gitignore
else
cat $TEMPLATE
fi