generate articles with makefile
This commit is contained in:
parent
bbd34e24ec
commit
b7729e5712
10
Makefile
10
Makefile
@ -22,6 +22,16 @@ default += .git/info/exclude
|
||||
.PHONY: database
|
||||
database: $(default) ## Make a database for recfiles
|
||||
|
||||
.PHONY: article
|
||||
article: ## Write an article
|
||||
@path=$$(find . -type d -printf '%P\n' | fzy); \
|
||||
read -p "Title: " title; \
|
||||
printf '%s\n' '---' >> $$path/$$title.md ; \
|
||||
printf 'title: "%s"\n' "$$title" >> $$path/$$title.md ; \
|
||||
printf 'tags: [ "%s" ]\n' "$$path" | sed 's#\/#", "#g' >> $$path/$$title.md ; \
|
||||
printf '%s\n\n' '---' >> $$path/$$title.md ;\
|
||||
$(EDITOR) +5 $$path/$$title.md
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(default)
|
||||
|
27
new.sh
27
new.sh
@ -1,27 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo Select a category
|
||||
|
||||
category="$(find . -type d -printf '%P\n' | fzy)"
|
||||
|
||||
[ ! -d "$category" ] && mkdir "$category"
|
||||
|
||||
echo Select a name
|
||||
|
||||
read name
|
||||
|
||||
filePath="$category/$(echo $name | sed 's/ /_/g').md"
|
||||
|
||||
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
|
||||
|
||||
[ -e "$filePath" ] && $EDITOR "$filePath" && exit 0
|
||||
|
||||
echo "---
|
||||
title: \"$name\"
|
||||
tags: [ $tagsList ]
|
||||
---
|
||||
|
||||
" > "$filePath"
|
||||
|
||||
$EDITOR "$filePath"
|
||||
|
Loading…
Reference in New Issue
Block a user