X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Fdrafts_prepend;fp=home%2Fbin%2Fdrafts_prepend;h=44df097873698a72d55e3f46599a55bcc3445278;hb=76b7ee108859ca2bd730297142b1d6ed73bfe053;hp=0000000000000000000000000000000000000000;hpb=ab62e6aca209988c969e730709a160c802693b2b;p=khome.git diff --git a/home/bin/drafts_prepend b/home/bin/drafts_prepend new file mode 100755 index 0000000..44df097 --- /dev/null +++ b/home/bin/drafts_prepend @@ -0,0 +1,18 @@ +#! /bin/bash + +set -euo pipefail + +FILE="$HOME/doc/drafts/drafts.md" + +bar() { + seq -s - 80 | sed -E 's/[0-9]+//g' +} + +header() { + printf 'untitled\n' + bar + date +'started: %Y-%m-%d %H:%M:%S %z' + printf '\n\n' +} + +(header && cat "$FILE") | sponge "$FILE" # sponge is in moreutils package