%> bash git_ignore.sh | cat -e
.DS_Store$
mywork.c~$
%>
Should be possible via git ls-files --ignored -X /path/to/gitignore. No need to write a dedicated script.
git ls-files --ignored -X /path/to/gitignore