Skip to content

Commit

Permalink
Add git-commit-each
Browse files Browse the repository at this point in the history
  • Loading branch information
jonchang committed Sep 13, 2020
1 parent c242948 commit c64b301
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions shell/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,28 @@ doi() {
done
}

git-commit-each() {
if [ -z "$1" ]; then
echo "Usage: git-commit-each <message> [<body>]"
return
fi

if ! [ -e .git ]; then
echo "Run this in a git directory!"
return
fi

for FILENAME in $(git ls-files --modified --others)
do
MESSAGE="$(echo "$FILENAME" | sed -e 's|^Library/Homebrew/||' \
-e 's|^Formula/||' \
-e 's|^Casks/||' \
-e 's/\.rb//' \
-e 's/$/: /')"
git add "$FILENAME"
git commit "$FILENAME" --message="${MESSAGE}${1}" --message="${2}"
done
}


# vim: ft=sh

0 comments on commit c64b301

Please sign in to comment.