#!/usr/bin/env zsh root=$0:h:a . $root/lib.zsh.rc usage() { die Usage: $0 ISSUE } [[ -n $1 ]] || usage issue=${1#issues/} comment=issues/$issue/comment $PERL -i -npe 's/^/# /' $comment zmodload -F zsh/stat b:zstat zstat -A ctimePrev +ctime $comment $EDITOR $comment zstat -A ctime +ctime $comment [[ $ctime != $ctimePrev ]] || { echo Aborting comment >&2 $PERL -i -npe 's/^# //' $comment exit 0 } $PERL -i -ne 'print if $can; if (/^$/) { $can=1 };' $comment git add $comment