Skip to content

Instantly share code, notes, and snippets.

@taikedz
Last active January 11, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taikedz/b3516b2d5f8769d04034da903be08559 to your computer and use it in GitHub Desktop.
Save taikedz/b3516b2d5f8769d04034da903be08559 to your computer and use it in GitHub Desktop.
Generate paths to un-ignore deeply nested directories for .gitignore
unignorepath() {
local super="$(dirname "$1")"
[[ "$super" =~ ^(.|/)$ ]] && return
unignorepath "$super" # process higher levels first so as to print in order
echo "$super/*"
echo '!'"$1"
}
echo -e "\n# Ignore nested folders\n"
for arg in "$@"; do
unignorepath "$arg"
done | sort | uniq
echo -e "\n# ------\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment