From aa3140fe6a1e0ad5084355e82ad757d4f3848ba9 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 23 Apr 2025 02:00:05 -0400 Subject: [PATCH] AutoYADM commit: 2025-04-23 02:00:05 --- .config/fish/functions/jrnl.fish | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/fish/functions/jrnl.fish b/.config/fish/functions/jrnl.fish index 558db3d5..4fa5295b 100644 --- a/.config/fish/functions/jrnl.fish +++ b/.config/fish/functions/jrnl.fish @@ -89,10 +89,15 @@ function jrnl --description 'Lightweight journaling tool' set entry "$jdir/$today.md" # check if journal entry exists if not test -f $entry - set contents (cat $template | \ - string match --invert --regex '^' | \ - string replace --all '%{date}' "$(date +'%A, %b %d, %Y')" | \ - string collect -N) + set lines (cat $template) + while test -z "$lines[-1]" + set -e lines[-1] + end + set contents ($lines | + string match --invert --regex '^' | + string replace --all '%{date_long}' "$(date +'%A, %b %d, %Y')" | + string replace --all '%{date}' "$today" | + string collect -N ) echo $contents return 0 # set contents (string join \n "# $today" "$(tail -n +2 $template)" | string collect -N)