Tool that makes it easier to find "zettels" in large zettelkastens.
To search for zettels containing the term "my zettelkasten" (or at least "my" and "zettelkasten"), simply type zkss my zettelkasten
in your terminal and press enter. This is what it can look like:
23-01-20_zkss_my_zettelkasten.mp4
The results are grouped, as you can see, and sorted by last accessed
. Every zettel occurs only once in the result list.
You can "pipe" the result to handle the output, e.g.
$ zkss my zettelkasten | grep "search"
Software like The Archive sort the search results by title, creation date or modification date. However, for some search terms, the more zettels you have, the more time you spend skimming the list of search results.
By structuring the search results and showing the presumably most relevant first, you should be able to save time finding the desired zettels.
First, you need Python, of course. On a Mac, it works best with Homebrew. I prefer pyenv because it can handle different versions of Python on the same machine.
Download the files above from GitHub (or use git clone https://github.com/ralfzosel/zk-smart-search.git
). I chose the directory code
in my home-directory.
.zshenv
, see below.
Usually, for Python, a virtual environment is recommended (though we only have one package to install with pip
- namely rich
for colorful results). This can be done with venv or via pyenv
(see above).
To be able to start the script in the terminal by simply typing zkss
, you have to add the following line to your .zshenv
-file in your home directory (on a Mac):
export PATH=~/code/zk-smart-search:$PATH
If you installed the script to another directory, you have to change the line.
Furthermore, to make colored output work, you have to add the following line to your .zshenv
-file:
export LESS=-r
Restart your terminal to make the changes of .zshenv
work.
Change the file settings.py
according to your needs:
ZK_BASE_DIR
is the directory where your zettels are stored.- Change
ENDING
to ".txt" if that's the ending you are using instead of ".md".
- Integrate smart search in The Archive. ;-)
Further ideas and improvements are welcome.
I have only tested on macOS, so I have now idea if it works on Windows, too.
When it comes to Python, I am just a hobbyist and this is my first project I am publishing on GitHub. So it's very likely I made some mistakes. Please bear with me.