From 981778a89150eed8c06028ab189df3dd604f1c57 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Tue, 27 Jun 2023 23:06:05 +0200 Subject: [PATCH] add new file script --- new.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 new.sh diff --git a/new.sh b/new.sh new file mode 100755 index 0000000..16867d0 --- /dev/null +++ b/new.sh @@ -0,0 +1,27 @@ +#!/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/$name.md" + +tagsList="$(echo \"$category | sed 's#\/#", "#g')\"" + +[ -e "$filePath" ] && $EDITOR $filePath && exit 0 + +echo "--- +title: \"$name\" +tags: [ $tagsList ] +--- + +" > "$filePath" + +$EDITOR "$filePath" +