From 724be92bb4e8cdb3404dcfe6ad6a7ce77665a999 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Wed, 16 Feb 2022 18:52:12 +0000 Subject: [PATCH] Utility script to create a new docs page with the correct ID Signed-off-by: Solomon Hykes --- docs/new.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 docs/new.sh diff --git a/docs/new.sh b/docs/new.sh new file mode 100755 index 00000000..b698fa3d --- /dev/null +++ b/docs/new.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +## Create a new documentation article + +function new() { + local name + name="$1" + if [ -z "$name" ]; then + echo >&2 "Usage: $0 NAME" + return 1 + fi + local last + last="$( + find . -name '[0-9]*.md' | + sed -E -e 's/^.*\/([0-9]+)-([^\/]*)\.md/\1/' | + sort -u -n | + tail -n 1 + )" + local next + ((next="$last"+1)) + + local filename="$next-$name.md" + echo "Creating $filename" + touch "$filename" +} + + +new "$@"