41 lines
621 B
Bash
Executable File
41 lines
621 B
Bash
Executable File
#!/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
|