Jump to content

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
Link to comment
  • 3 weeks later...

@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
Link to comment

@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
Link to comment

@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 :)

 

Link to comment

@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 :) 

Link to comment

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! 

 

 

 

 

Link to comment
  • 1 month later...
  • 4 weeks later...

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
Link to comment
  • 3 weeks later...

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!

Link to comment
  • 2 weeks later...
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!

Link to comment
  • 4 months later...
  • 2 months later...

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}"

 

Link to comment
  • 3 months later...

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
×
×
  • Create New...