Jump to content
chrisbro

Bear workflow - search and create notes

Recommended Posts

Hey everyone! I've created a workflow that allows you to search and create notes for Bear. This is my first workflow, first OSS project, and first foray into Python - let me know what all I messed up :) Available on github and Packal. Many thanks to @deanishe and @dfay for some initial direction.

 

Install

To install, download a released alfred-bear workflow and double-click to open in Alfred 3. Easy-peasy.

Searching and opening results

bs -- Search for a note by title and open it in Bear.

 

bs.png

 

 

bst -- Search for a tag (a group of notes) by tag title and open it in Bear.

bst.png

Creating a new note

bn I love notes! -- Creates a new note with the title and text "I love notes!"

bn1.png

 

 

bn I love notes! #love #notes -- Creates a new note with the title and text "I love notes!" and the tags "#love" and "#notes"

bn2.png

Known Issues

  • Creating tags only works with single-word tags - multiword tags hopefully to come.

Todo

  • Append text to existing notes.
  • Figure out multi-word tags.

Thanks

Versions

0.3.1

  • Fixed database location that changed with a Bear update.

0.3.0

  • Added search results from note text to main search.

0.2.2

  • Changed search queries to order by last modified date descending, so that more recently modified notes/tags show up at the top.

0.2.1

  • Added hashtag symbol to "Open Tag" list results to make it a little more obvious that it's a tag and not a note.

0.2.0

  • Now allows non-ASCII characters.
  • Searching by tag now displays not only tags that match the search query, but notes that match those tags as well.
  • Searching by tag now works with or without the '#' symbol in front of the tag.

 

0.1.0 

  • Initial public release.
Edited by chrisbro
0.3.1 release

Share this post


Link to post

Hey, nice workflow! Thanks! Unfortunately, it doesn't work anymore since the latest update from Bear (Version 1.2.2) :(

That is the error message: 

 

image.png.a7090e705b0ce4ca2ab8bd8ca85ca27b.png

Share this post


Link to post

@td. As a rule, pictures aren't much help with trying to diagnose and fix problems.

 

At a minimum, please also include any output in Alfred's debugger. 

Share this post


Link to post

@td. it seems the path to Bear database has changed (or I don't know, I just tried the workflow now since your post made me think that I could look at a workflow for Bear...). @chrisbro, I made it works by changing the database path in the script "queries.py" at line 11 to 13

 

From:

DB_LOCATION = (
    "/Library/Containers/net.shinyfrog.bear/Data/Library/Application Support/"
    "net.shinyfrog.bear/database.sqlite")

To:

DB_LOCATION = (
	"/Library/Containers/net.shinyfrog.bear/Data/Documents/Application Data/database.sqlite")

Also, ( @td., you may need to do that as well) the cached database didn't update so I deleted the "db_path.cpickle" in "~/Library/Application Support/Alfred 3/Workflow Data/com.chrisbro.bear/db_path.cpickle" and after that, now everything seems to be working

 

Here is an updated version while @chrisbro update his version : https://nofile.io/f/wSoOfp0ILrP/Bear.alfredworkflow

Edited by GuiB

Share this post


Link to post

@td. @GuiB

 

Thanks for the heads up, y'all! I hadn't updated Bear yet with its recent update so hadn't detected it yet. Sure enough, upgrading in the App Store broke it.

 

Let me hack up a fix real quick and release it.

Share this post


Link to post

@td. @GuiB Fixed! Again, thanks so much for bringing it to my attention. I hacked up a cache bust to fix the location it points to - it checks the location key, and if it detects the old version, attempts to find the new version instead. Hopefully this is backwards-compatible for people who haven't upgraded - I'll test it out when I get to work since I haven't upgraded Bear there yet.

Edited by chrisbro

Share this post


Link to post

@chrisbro @GuiB Awesome, it works. Thanks man :)

 

 

One more thing: 

When you type bn title #tag it creates a note with title as h1 and as content. Like this: 

# title 
title 

#tag

Shouldn't it be just like this: 

# title 
#tag

 

Or is it a known issue or even by design? 

Thanks :)

 

Share this post


Link to post

@td. I guess I could say it was "by design" but I think that's giving me too much credit. I didn't know which approach I'd like (or users would like) so I had it write the Alfred text entry to both title and text. You're the second or third person to ask me if that's a bug or not, though, so at this point I'm going to remove it for the next version :) 

Share this post


Link to post

Ok, nice :) Let me chip in some ideas if you like. 

 

Note creating (bn)

1. Focus the editor afterward, so you can start typing your note right away

2. Automatically insert two breaks after the tag like in the following image. That's my default layout and I assume the one from the majority? Maybe, I don’t know! 

image.png.bcbf03a16130e594cf7a0ecbf8b9e4a5.png

3. Show tag suggestions as soon as you type # like in bs. That would be awesome!

 

Yeah, that’s it for now. Nice that you are so responsive! 

 

 

 

 

Share this post


Link to post

Just wanna say thank you for the wonderful work!! : )

 

request: multi word search

Edited by dunkaroo

Share this post


Link to post

Thanks for the workflow, this is exactly what I was looking for! Maybe I'm finally ready to transfer my recipe bookmarks from browser to Bear as I'm able to search for them properly.

BTW I had the same error than Jakub here before me and I thought the workflow is just broken. Now after few weeks I decided to try again and it works like a charm! What changed in between? I went Pro! Maybe that could affect this workflow? Not sure though, but if that's the problem you might want to add a note about it in Github.

Edited by turanturan

Share this post


Link to post

I'm reaching out to the Bear support channel to see what's causing this "no such table" error - it's tough to reproduce even on similar setups, and a reboot fixed it for someone out there experiencing it. If I can figure out what the deal is I'll try to code around it!

Share this post


Link to post
On 7/21/2017 at 2:04 PM, td. said:

Ok, nice :) Let me chip in some ideas if you like. 

 

Note creating (bn)

1. Focus the editor afterward, so you can start typing your note right away

2. Automatically insert two breaks after the tag like in the following image. That's my default layout and I assume the one from the majority? Maybe, I don’t know! 

image.png.bcbf03a16130e594cf7a0ecbf8b9e4a5.png

3. Show tag suggestions as soon as you type # like in bs. That would be awesome!

 

Yeah, that’s it for now. Nice that you are so responsive! 

 

 

 

 

I second this suggestion. This is exactly the way I do my notes. Great workflow!

Share this post


Link to post

I'm not sure if anyone else has run into this, but it seems like the ability to open a tag in bear does not work if a tag has spaces in it. I'm guessing something's not getting encoded properly somewhere? 

Share this post


Link to post

I found the bug fix for tags with spaces. In the script that is run by the Bear Search Tag trigger to open Bear, the first line of the script is:

 

orig_query={query}

It needs to be changed to enclose {query} in quotes otherwise any tag with spaces in it will fail. Here is what the corrected line should be:

orig_query="{query}"

 

Share this post


Link to post

Ahoy, looks like Shiny Frog has moved away from sqlite for their backend in the latest release. I've emailed support to confirm and will make a PR on GitHub if there's an easy fix, otherwise if anybody knows more than I do right now that would be great :) 

Share this post


Link to post

I'm still getting the same "no such table: ZSFNOTE" using the latest workflow version 0.3.2. I tried uninstalling the previous version and installing the latest  but I still get the error.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×