AutoYADM commit: 2025-04-23 02:15:06
This commit is contained in:
parent
aa3140fe6a
commit
49c4bb7d98
1 changed files with 21 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
function jrnl --description 'Lightweight journaling tool'
|
function jrnl --description 'Lightweight journaling tool'
|
||||||
argparse h/help d/dir=? -- $argv
|
argparse h/help d/dir=? e/edit -- $argv
|
||||||
if set -q _flag_h
|
if set -q _flag_h
|
||||||
echo jrnl: a lightweight journaling tool
|
echo jrnl: a lightweight journaling tool
|
||||||
echo
|
echo
|
||||||
|
@ -8,6 +8,9 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
echo Usage:
|
echo Usage:
|
||||||
echo \tOpen today\'s entry:
|
echo \tOpen today\'s entry:
|
||||||
echo \t\> jrnl
|
echo \t\> jrnl
|
||||||
|
echo \tEdit the template:
|
||||||
|
echo \t\> jrnl -e
|
||||||
|
echo \t\> jrnl --edit
|
||||||
echo \tSet the journal directory "(~/jrnl)" by default:
|
echo \tSet the journal directory "(~/jrnl)" by default:
|
||||||
echo \tWith environment variable \'jrnl_directory\':
|
echo \tWith environment variable \'jrnl_directory\':
|
||||||
echo \t\> set -Ug jrnl_directory path/to/journal
|
echo \t\> set -Ug jrnl_directory path/to/journal
|
||||||
|
@ -81,7 +84,6 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# get the date
|
# get the date
|
||||||
|
@ -89,19 +91,24 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
set entry "$jdir/$today.md"
|
set entry "$jdir/$today.md"
|
||||||
# check if journal entry exists
|
# check if journal entry exists
|
||||||
if not test -f $entry
|
if not test -f $entry
|
||||||
set lines (cat $template)
|
# set lines (cat $template)
|
||||||
while test -z "$lines[-1]"
|
# while test -z "$lines[-1]"
|
||||||
set -e lines[-1]
|
# set -e lines[-1]
|
||||||
end
|
# echo empty
|
||||||
set contents ($lines |
|
# end
|
||||||
string match --invert --regex '^<!--.*-->' |
|
# echo $lines
|
||||||
string replace --all '%{date_long}' "$(date +'%A, %b %d, %Y')" |
|
set contents (cat $template | \
|
||||||
string replace --all '%{date}' "$today" |
|
string match --invert --regex '^<!--.*-->' | \
|
||||||
|
string replace --all '%{date_long}' "$(date +'%A, %b %d, %Y')" | \
|
||||||
|
string replace --all '%{date}' "$today" | \
|
||||||
string collect -N)
|
string collect -N)
|
||||||
echo $contents
|
set contents (string trim --right $contents | string collect -N)
|
||||||
return 0
|
# echo -n $contents
|
||||||
|
# echo $contents
|
||||||
|
# echo $contents | string collect -N
|
||||||
|
# return 0
|
||||||
# set contents (string join \n "# $today" "$(tail -n +2 $template)" | string collect -N)
|
# set contents (string join \n "# $today" "$(tail -n +2 $template)" | string collect -N)
|
||||||
cat $template >$entry
|
echo -n "$contents" >$entry
|
||||||
set -l prompt "Created $entry, open in $EDITOR? (y/n)"
|
set -l prompt "Created $entry, open in $EDITOR? (y/n)"
|
||||||
while read --nchars 1 -l response --prompt-str="$prompt" or return 1
|
while read --nchars 1 -l response --prompt-str="$prompt" or return 1
|
||||||
printf "\033[1A\033[2K"
|
printf "\033[1A\033[2K"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue