Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 9, 2017 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudelson/5b5c4ab005b65149d68ec5d45918450b to your computer and use it in GitHub Desktop.
Save dudelson/5b5c4ab005b65149d68ec5d45918450b to your computer and use it in GitHub Desktop.
The git pre-commit hook for my website. Responsible for building my blog archives and updating the "Last updated" info in the footer.
#!/usr/bin/sh
# this line is necessary to get the script to run in magit
PATH=$PATH:~/.gem/ruby/2.3.0/bin
echo "Running jekyll pre-build..." \
&& bundle exec jekyll build \
&& echo "Generating archives..." \
&& ruby blog/archive/_generator.rb \
&& git add blog/archive/dates blog/archive/tags \
&& echo "Done!" \
&& echo \
&& echo "Updating site footer..." \
&& sed -i -- "s.[[:digit:]]\{4\}/[[:digit:]]\{2\}/[[:digit:]]\{2\}.$(date +'%Y/%m/%d')." _includes/footer.html \
&& echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment