bin: add git-ignore

This commit is contained in:
Fernando Schauenburg 2024-07-23 11:32:47 +02:00
parent 71c07b1998
commit c0dea465da

26
bin/git-ignore Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
set -eu
WORKDIR="${XDG_CACHE_HOME:-$HOME/.cache}/git-ignore"
URL="https://github.com/github/gitignore.git"
if [ ! -d "$WORKDIR" ]; then
git clone --quiet --depth 1 "$URL" "$WORKDIR"
else
git -C "$WORKDIR" pull --quiet
fi
find "$WORKDIR" -maxdepth 1 -type f -name '*gitignore' |
sed -e "s,^$WORKDIR/\(.*\)\.gitignore$,\1," |
sort |
fzf --multi \
--preview="cat $WORKDIR/{}.gitignore" \
--bind='ctrl-p:toggle-preview' |
while read -r lang; do
echo "############################################################"
echo "# ${lang}"
echo "############################################################"
cat "$WORKDIR/${lang}.gitignore"
echo
done