One minute
202109102056
Hugo convenience script that does a commit and deploy. This drops the
activation energy for posting; just run $ bin/h
, it launches an
editor, and if you quit without triggering an error code, the post is
posted.
In vim, quitting with an error code is pronounced :cq
.
#!/usr/bin/env ruby
def xexec(cmd)
system cmd
fail unless $?.success?
end
datestr = `date +%Y%m%d%H%M`.strip
filename = "posts/#{datestr}.md"
system "hugo new #{filename} --editor #{ENV['EDITOR']}"
if $?.success?
xexec "git add content/#{filename}"
xexec "git commit -m '#{filename}'"
xexec "make deploy"
xexec "git push"
else
xexec "rm content/#{filename}"
end