Skip to content

Instantly share code, notes, and snippets.

@nevstokes
Last active April 14, 2019 19:44
Show Gist options
  • Save nevstokes/282ca190de58a3ff032bcdfb8e692185 to your computer and use it in GitHub Desktop.
Save nevstokes/282ca190de58a3ff032bcdfb8e692185 to your computer and use it in GitHub Desktop.
Generate individual ignore files from unified yaml
eslint:
- node_modules/
- "*.d.ts"
docker:
- .env.dist
- node_modules
- README.md
git:
- .*ignore
- .env
- bin/*.js
- lib/*.js
- "*.d.ts"
- node_modules
npm:
- "*.ts"
- !*.d.ts
#!/usr/bin/env bash
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 IGNOREFILE" >&2
exit 1
fi
IGNOREFILE=$1
if ! [[ -f "${IGNOREFILE}" ]]; then
echo "${IGNOREFILE} not found" >&2
exit 1
fi
while read ignore; do
match=$(printf '/^%s:/,/^[^\s-]+:/p' ${ignore})
output=$(printf '.%signore\n' ${ignore})
sed -nE ${match} ${IGNOREFILE} | sed -nE 's/^\s*-\s*//p' > ${output}
done < <(sed -nE 's/^([a-z]+):/\1/p' ${IGNOREFILE})
@nevstokes
Copy link
Author

nevstokes commented Apr 11, 2019

Unified ignore

I'm fed up of having several ignore files littering my repositories. This script will generate many ignores from one keyed yaml file.

Usage

$ ./generate.sh .ignore.yaml

zsh plugin

A plugin for zsh is available to automatically create the individual ignore files upon entering a directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment