add new file script

This commit is contained in:
Malin Freeborn 2023-06-27 23:06:05 +02:00
parent e1d69bbcf2
commit 981778a891
Signed by: andonome
GPG Key ID: 52295D2377F4D70F

27
new.sh Executable file
View File

@ -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"