#!/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