Created
January 21, 2023 01:39
-
-
Save Digital-Grinnell/49a746444f44abed4ab1d0210d25b52f to your computer and use it in GitHub Desktop.
My pre-commit Git Hook
This file contains 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
# Contents of ~/gitconfig/hooks/pre-commit | |
# Replace `last_modified_at` timestamp with current time in the specified TZ for .md edits only | |
# Note that this file should exist on your workstation as `~/gitconfig/hooks/pre-commit` and the file must be executable! | |
git diff --cached --name-status | egrep -i "^(A|M).*\.(md)$" | while read a b; do | |
cat $b | sed "/---.*/,/---.*/s/^last_modified_at:.*$/last_modified_at: $(TZ=CST6CDT date "+%Y-%m-%dT%H:%M:%S")/" > tmp | |
mv tmp $b | |
git add $b | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment