Last active
January 11, 2019 10:30
-
-
Save taikedz/b3516b2d5f8769d04034da903be08559 to your computer and use it in GitHub Desktop.
Generate paths to un-ignore deeply nested directories for .gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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