dkaslovsky/textnote

Enhancement suggestion

imarsman opened this issue · 4 comments

I hesitate to ask this but if I take a few days off the -c parameter requires that I remember which day I last made a note for. It would be useful to have it where if there were no value for the c parameter textnote would cycle back and find the last day's note. I have not looked at the code for textnote so don't know if the filename is guaranteed to match the date for that note, but if it is cycling back should work. I really enjoy using textnote. Thank-you for both writing it and making it available.

Hi @imarsman, thanks for the suggestion and for the kind words. I'm really glad to hear that you are using and finding value in textnote!

I think the suggested enhancement is a good one and makes a lot of sense. I also find myself wanting a similar feature. I did not implement it initially because there wasn't a clear way to do it efficiently. Because the date format can be specified in the configuration, we are not guaranteed that sorting the string file names will give us the most recent file. I also considered decrementing the time.Time object by one day and checking if that file exists - if it doesn't decrement again and keep going. In the case where textnote hasn't been used for a long time, this would result in many calls to os.stat. Let me think on the best way to approach this and I will see about implementing it in the next few days.

FWIW - because I do use lexicographically sortable date conventions for my file names (textnote's default), we can rely on sorting to get the latest. So, my current workflow for accomplishing what you are asking about is:

textnote open --copy $(tnlatest) -s TODO -x

where tnlatest is the following function:

tnlatest () {
	ls -lhFG $TEXTNOTE_DIR | grep -v 'archive' | awk '{print $9}' | sort -r | head -n 1 | cut -f 1 -d '.'
}

While this works, I would like to make it a proper part of textnote as you suggested and make it robust to any date formatting.

Thanks again and I'll update here in a few days!

Thanks! That's great!

I believe I have a reasonable implementation, look for a new release in a day or two (maybe even sooner)!

The enhancement, along with several other changes are available in the latest v1.2.0 release.

Thank you again for opening this issue and for using textnote!