Skip to content

Instantly share code, notes, and snippets.

View iehtian's full-sized avatar

chen ying iehtian

View GitHub Profile
@iehtian
iehtian / pre-commit
Last active November 21, 2025 12:54
hexo auto update updatedtime
git status -s | grep '^[MA]' | while read status file; do
# 去除可能存在的引号
file=$(echo "$file" | sed 's/^"//;s/"$//')
if [[ "$file" == *"source/_posts"* && "$file" == *".md" ]]; then
now=$(date +"%Y-%m-%d %H:%M:%S")
sed -i "s/^updated:.*/updated: \"$now\"/" "$file"
git add "$file"
echo "Updated timestamp for: $file"
fi
done