AutoYADM commit: 2025-04-23 23:15:05
This commit is contained in:
parent
8fb20348d6
commit
453cfaf91e
2 changed files with 23 additions and 3 deletions
|
@ -2,3 +2,4 @@ complete -c jrnl -s h -l help -d 'Print help'
|
||||||
complete -c jrnl -s e -l edit-template -d 'Edit the journal entry template'
|
complete -c jrnl -s e -l edit-template -d 'Edit the journal entry template'
|
||||||
complete -c jrnl -s d -l dir -d 'Set the journal directory' -r
|
complete -c jrnl -s d -l dir -d 'Set the journal directory' -r
|
||||||
complete -c jrnl -s t -l template -d 'Set the template file' -r
|
complete -c jrnl -s t -l template -d 'Set the template file' -r
|
||||||
|
complete -c jrnl -s o -l offset -d 'Set hours from midnight for start of tomorrow' -r -f
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function jrnl --description 'Lightweight journaling tool'
|
function jrnl --description 'Lightweight journaling tool'
|
||||||
argparse h/help d/dir= t/template= e/edit-template -- $argv
|
argparse h/help d/dir= t/template= e/edit-template o/offset= -- $argv
|
||||||
if set -q _flag_h
|
if set -q _flag_h
|
||||||
echo (set_color -o)jrnl: a lightweight journaling tool(set_color normal)
|
echo (set_color -o)jrnl: a lightweight journaling tool(set_color normal)
|
||||||
echo
|
echo
|
||||||
|
@ -8,6 +8,11 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
echo (set_color -o)Usage:(set_color normal)
|
echo (set_color -o)Usage:(set_color normal)
|
||||||
echo (set_color -o)\tOpen today\'s entry:(set_color normal)
|
echo (set_color -o)\tOpen today\'s entry:(set_color normal)
|
||||||
echo \t\> jrnl
|
echo \t\> jrnl
|
||||||
|
echo (set_color -o)\tSet a time offset '(in hours, from midnight)'
|
||||||
|
echo \tfor start of the next day '(default: 3)':(set_color normal)
|
||||||
|
echo \t\> set -Ug jrnl_offset 2
|
||||||
|
echo \t\> jrnl -o 2
|
||||||
|
echo \t\> jrnl --offset 2
|
||||||
echo (set_color -o)\tEdit the template:(set_color normal)
|
echo (set_color -o)\tEdit the template:(set_color normal)
|
||||||
echo \t\> jrnl -e
|
echo \t\> jrnl -e
|
||||||
echo \t\> jrnl --edit-template
|
echo \t\> jrnl --edit-template
|
||||||
|
@ -99,8 +104,22 @@ function jrnl --description 'Lightweight journaling tool'
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# get the date
|
set -g offset 3
|
||||||
set today (date +'%Y-%m-%d')
|
if set -ql _flag_offset[1]
|
||||||
|
echo flag is set
|
||||||
|
set offset $_flag_offset[1]
|
||||||
|
else if set -q jrnl_offset
|
||||||
|
set offset $jrnl_offset
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_date -a fmt
|
||||||
|
if test (date +%H) -lt "$offset"
|
||||||
|
date -d yesterday +"$fmt"
|
||||||
|
else
|
||||||
|
date +"$fmt"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set today (get_date '%Y-%m-%d')
|
||||||
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue