lk/new.sh

28 lines
412 B
Bash
Raw Normal View History

2023-06-27 21:06:05 +00:00
#!/bin/sh
echo Select a category
category="$(find . -type d -printf '%P\n' | fzy)"
[ ! -d "$category" ] && mkdir "$category"
echo Select a name
read name
2023-07-08 18:02:11 +00:00
filePath="$category/$(echo $name | sed 's/ /_/g').md"
2023-06-27 21:06:05 +00:00
tagsList="$(echo \"$category | sed 's#\/#", "#g')\""
2024-04-06 00:00:09 +00:00
[ -e "$filePath" ] && $EDITOR "$filePath" && exit 0
2023-06-27 21:06:05 +00:00
echo "---
title: \"$name\"
tags: [ $tagsList ]
---
" > "$filePath"
$EDITOR "$filePath"