From 41b18b8b05342daae4030455b7d23259df1d02a4 Mon Sep 17 00:00:00 2001 From: veclav talica Date: Fri, 16 Feb 2024 20:00:26 +0500 Subject: [PATCH] new-article.sh: utility for creation of article stub in cli --- new-article.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 new-article.sh diff --git a/new-article.sh b/new-article.sh new file mode 100755 index 0000000..76ba79c --- /dev/null +++ b/new-article.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set +e + +printf "%s" "Enter title: " +read title + +printf "%s" "Enter directory name: " +read directory + +if [ -d "./articles/$directory/" ]; then + echo "Directory already exists, aborted." + exit +fi + +printf "%s" "Enter brief: " +read brief + +printf "%s" "Enter tags: " +read tags + +mkdir "./articles/$directory/" + +mask=$(cat <<-format +Title: %s +Brief: %s +Date: %s +Tags: %s +CSS: /style.css + +format +) +date=$(date +%s) + +printf "$mask" "$title" "$brief" "$date" "$tags" \ + > "./articles/$directory/page.mmd" + +if which xdg-open &> /dev/null; then + xdg-open "./articles/$directory/page.mmd" +fi