Skip to content

Instantly share code, notes, and snippets.

@prati0100
Created September 30, 2018 11:15
Show Gist options
  • Save prati0100/c27ece230389fb0bd71a594b9701c9d4 to your computer and use it in GitHub Desktop.
Save prati0100/c27ece230389fb0bd71a594b9701c9d4 to your computer and use it in GitHub Desktop.
A script to automatically update the last updated of my resume. Run it as a post-commit hook.
#!/bin/bash
# This script automatically updates the Last updated section of my resume
# First, stash whatever changes that are left in the tree and should not be
# committed
git stash &> /dev/null
# Now get today's date and replace that in resume.tex
DATE=`date "+%d %B, %Y"`
sed "s/{Last updated.*}/{Last updated $DATE}/" resume.tex >resume.tex.tmp && mv resume.tex.tmp resume.tex
if [[ $? -ne 0 ]]; then
exit $?
fi
# Disable the post-commit hook temporarily, otherwise it will cause an infinite
# loop
GITDIR=`git rev-parse --git-dir`
POSTHOOK="$GITDIR/hooks/post-commit"
mv $POSTHOOK $POSTHOOK.tmp
# Now commit the changes and pop the stash.
git commit -a --amend --no-edit --no-verify > /dev/null
git stash pop &> /dev/null
# Re-enable the post-commit hook
mv $POSTHOOK.tmp $POSTHOOK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment