Skip to content

Exclude directories from search #446

Description

@cygaj

(I haven't yet read the entire doc, I couldn't find anything relevant with ctrl+F, but I may as well missed a solution if it's already documented)

Hi! I'd like to exclude a directory from search inside a notebook. I tried to specify a path after --not operator but it apparently did nothing.

In regular search I solved the issue with a bash function that pipes results to grep (altho it's not ideal since I was at a loss how to grep for color escape codes so I used --no-color but now the results are less readable… because there is no color). But the problem appeared again when I tried to list the tags with nb --tags and realized I can't grep to exclude a path if it's not mentioned in the output.

My use case is: I wanted to setup archive directories inside non-archived notebooks. I know I could set up a separate archived notebook and sort archived items from other notebooks in separate directories, but I still want to keep notes on one topic in one notebook to keep the ability to search for all.

I wish I could exclude a directory from search either way (it might be already there but I simply missed it in the docs! or didn't figure out the syntax on my own), but another feature that would be interesting to me would be archiving directories inside non-archived notebooks with an .archived files in those folders.

I would also enjoy an option to override the .archived setting while doing a global search with --all.


PS. Unrelated to the ability to exclude folders in search I just figured out I can solve my issue around archiving files inside active folders by adding an #archived hashtag to notes and instead of piping my search to grep append --not -t archived arguments. Still don't know how to list tags with exclusion.
I am a beginner so I might still prefer a folder solution because it's easier to move files around in bulk than to manipulate them but maybe it's an excuse to get better at bash ;•)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions