From 81889f62e07f43491d4647b701a4bc927181f077 Mon Sep 17 00:00:00 2001 From: Ayo Date: Thu, 25 Jun 2026 14:48:13 +0200 Subject: [PATCH] feat(notes): provide note title as arg --- notes.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/notes.sh b/notes.sh index 40ca8e9..684be83 100755 --- a/notes.sh +++ b/notes.sh @@ -22,7 +22,11 @@ function editFile() { function createNote() { { - read -p "Create new note: " title + if [ "$1" = "" ]; then + read -p "Create new note: " title + else + title="${@:1}" + fi if [ "$title" = "" ]; then echo "Title cannot be empty." @@ -30,19 +34,21 @@ function createNote() { fi; file_date="$(date +'%Y.%m.%d')" - file_name=$title.md + file_name="$title.md" full_path="${notes_dir}/${file_date}-${file_name}" - # IF Not Exists: create file & echo date + # IF Not Exists: create file with: + # - title + # - date & time if ! test -f "$full_path"; then install -Dv /dev/null "$full_path" >/dev/null - # TODO: update to correct heading from old entries heading="# $title" echo "$heading" > "$full_path" date_heading=$(date +'%b %d, %Y, %a %r') echo "$date_heading" >> "$full_path" fi + # Edit the new / existing file editFile "$full_path" } || { @@ -138,7 +144,7 @@ function main() { # DEFAULT: Default action - create new note *) - createNote + createNote $2 ;; esac }