new-article.sh: utility for creation of article stub in cli
This commit is contained in:
parent
d7a434ea11
commit
41b18b8b05
40
new-article.sh
Executable file
40
new-article.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user