From 6d448e865e96895ccc04c1f2f1ec2e957cf78c3d Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Mon, 25 Mar 2024 19:28:17 +0100 Subject: [PATCH] Script for notes for blog posts. --- home-manager/modules/scripts/pblog | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 home-manager/modules/scripts/pblog diff --git a/home-manager/modules/scripts/pblog b/home-manager/modules/scripts/pblog new file mode 100755 index 0000000..3f41253 --- /dev/null +++ b/home-manager/modules/scripts/pblog @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +if [ $# -eq 0 ]; then + cd "$SECOND_BRAIN"/blog || exit 1 + nvim + exit 0 +fi + +open_file() { + cd "$SECOND_BRAIN"/blog || exit 1 + nvim "${1}.md" +} + +remove_file() { + cd "$SECOND_BRAIN"/blog || exit 1 + if [ -f "${1}.md" ]; then + rm "${1}.md" + else + echo "File didn't exist" + fi +} + +if [ $# -ne 2 ]; then + echo "You need to provide action and file name." + exit 1 +fi + +case "$1" in +edit) + open_file "$2" + exit 0 + ;; +rm) + remove_file "$2" + exit 0 + ;; +*) + exit 1 + ;; +esac