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