mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 14:14:24 -05:00
new daily_finder without the ability to create notes - done by the
plugin
This commit is contained in:
@@ -2,16 +2,13 @@
|
|||||||
|
|
||||||
# daily_finder for telekasten.nvim
|
# daily_finder for telekasten.nvim
|
||||||
#
|
#
|
||||||
# gives the plugin the ability to search for daily notes,
|
# actually, this is now the standard finder in telekasten
|
||||||
# - sorted by date
|
|
||||||
# - creates today's note if not present, with hardcoded template
|
|
||||||
|
|
||||||
if [ "$1" == "check" ] ; then
|
if [ "$1" == "check" ] ; then
|
||||||
echo OK
|
echo OK
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# if called by the plugin, no args are provided, and the current working
|
# if called by the plugin, no args are provided, and the current working
|
||||||
# directory is set instead
|
# directory is set instead
|
||||||
if [ "$1" == "" ] ; then
|
if [ "$1" == "" ] ; then
|
||||||
@@ -20,35 +17,5 @@ else
|
|||||||
the_dir=$1
|
the_dir=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# function DaySuffix:
|
# sort reversed numerical
|
||||||
# little helper to give us st, nd, th for 1st, 2nd, 3rd, 4th, ...
|
find $the_dir -type f | sort -rn
|
||||||
DaySuffix() {
|
|
||||||
case `date +%d` in
|
|
||||||
1|21|31) echo "st";;
|
|
||||||
2|22) echo "nd";;
|
|
||||||
3|23) echo "rd";;
|
|
||||||
*) echo "th";;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# path to today's note
|
|
||||||
dailyfile=$the_dir/$(date --iso).md
|
|
||||||
|
|
||||||
# function CreateDaily:
|
|
||||||
# create today's daily note with hardcoded template
|
|
||||||
CreateDaily() {
|
|
||||||
daysuffix=$(DaySuffix)
|
|
||||||
daystr=$(LC_TIME=en_US.UTF-8 date +"%A, %B %d$daysuffix, %Y")
|
|
||||||
datestr="title: $daystr"
|
|
||||||
echo --- >> $dailyfile
|
|
||||||
echo $datestr >> $dailyfile
|
|
||||||
echo --- >> $dailyfile
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$(basename $the_dir)" == "daily" ] ; then
|
|
||||||
if [ ! -f $dailyfile ] ; then
|
|
||||||
$(CreateDaily)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
find $the_dir -type f| sort -rn
|
|
||||||
|
|||||||
Reference in New Issue
Block a user