4 if [[ "$cmd" == "help" ]] ||
[[ "$cmd" != "run" && "$cmd" != "dry-run" ]]
6 if [[ "$cmd" != "help" ]]
8 echo "Error: Unrecognized command '$0 $1'"
13 echo " update_gitignore.sh run"
14 echo " update_gitignore.sh dry-run"
16 echo "This command finds all untracked and un-git-add-ed files in the repository and adds each file name to "
17 echo "a '.gitignore' file in the same directory. If a '.gitignore' file does not exist, one will be created. "
18 echo "Otherwise, the existing '.gitignore' file will be appended to. The 'dry-run' command enables you to "
19 echo "see a list of all detected file names that will be added to '.gitignore' files without making any "
22 echo "If the 'run' command does its job properly, running 'dry-run' immediately after should display no "
23 echo "planned actions."
25 if [[ "$cmd" == "help" ]]
35 for line
in $
(git status
--short --untracked-files)
37 if [[ $line == '??'* ]]
40 d
="$(dirname "${file}")"
41 f
="$(basename "${file}")"
43 if [[ "$cmd" == "run" ]]
45 echo "Ignoring ${f} in ${d}/.gitignore"
46 echo "${f}" >> "${d}/.gitignore"
48 echo "Will ignore ${f} in ${d}/.gitignore"