pimterry/notes

Feature Request: notes grep should show the notes content entries

arael opened this issue · 5 comments

arael commented

I think that notes grep command should not only list the notes title but also show the lines where the pattern has been found.

I'd like to do that, but it's slightly tricky since it's useful to be able to pipe the matched filenames elsewhere (notes grep <pattern> | notes open). I think there's two options:

  • Add a --show-matches option to do this
  • Detect whether your output is going to a pipe or a tty, and show more or less detail based on that (as discussed on #9 too).

What do you think?

arael commented

I see. Perhaps we could use a different command such as notes cgrep or notes lines.
I think the --show-matches is too long but it would avoid having a new command.

What about the 2nd option? If notes grep normally printed output that including matching details, but didn't included those details when piped, would that work for you?

E.g. like this:

> notes grep <pattern>
my-note.md:
blah blah blah *matching text* blah blah
another-note.md:
more *matching text* blah blah
> notes grep <pattern> | cat
my-note.md
another-note.md
arael commented

That would be very handy. But I am afraid the users would expect the pipe to contain the content as well and not only the file list.

I've opened a new ticket (#22) tracking the underlying issue here: we need a way to get snippets of any set of notes that doesn't break piping. I'm going to close this and track it over there - feel free to add your opinions there, or start looking at implementation options. Thanks for getting involved!