commit a8de07b07ea0acd775ed4355a3f101cfbd79f374
parent 780baaa0e6badfa4dea4986391cc31b2c84a1d67
Author: pyratebeard <root@pyratebeard.net>
Date: Fri, 23 Sep 2022 21:39:10 +0100
comments
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/scripts/draft b/scripts/draft
@@ -1,16 +1,20 @@
#!/bin/sh
+# use arg as title and set post file path
TITLE=$1
POST="entry/${TITLE}.md"
+# checkout the correct branch
git branch | grep ${TITLE} && \
git checkout ${TITLE} || \
git checkout -b ${TITLE}
+# if post file does not exist yet touch it
[ -f "${POST}" ] || touch "${POST}"
+# open post file in favourite editor
vim "${POST}"
+# when vim closes add and commit the changes
git add "${POST}"
-
git commit -S -m "${TITLE}"
diff --git a/scripts/publish b/scripts/publish
@@ -1,19 +1,25 @@
#!/bin/sh
+# use arg as title and set post file path
+# set published file path with date
TITLE=$1
POST="entry/${TITLE}.md"
PUBLISH="entry/$(date +%Y%m%d)-${TITLE}.md"
+# checkout the correct branch
git branch | grep ${TITLE} && \
git checkout ${TITLE} || \
git checkout -b ${TITLE}
+# rename post to set date
git mv "${POST}" "${PUBLISH}"
+# commit the rename as published
git commit -S -m "publish ${TITLE}"
+# checkout main branch and merge published post
git checkout main
-
git merge "${TITLE}"
+# push new post
git push