czottmann / bearing

Bearing, a scripting helper for Bear, the cuddly macOS notes app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bearing, a scripting helper for Bear

What it does

Bearing allows for scripting Bear. Out of the box, Bear can be automated using its x-callback-url API, meaning you call a URI (open "bear://x-callback-url/[action]?[action parameters]&[x-callback parameters]") to do things. Bearing adds to that by slightly abstracting and enhancing the experience:

  1. There's a dedicated bearing CLI tool that accepts plain arguments. You don't have to URL-encode anything.
  2. The CLI tool returns callback responses as JSON.

Usage

/usr/local/bin/bearing ACTION [parameters]

ACTION is the Bear action to call (e.g., 'open-note', 'create', 'add-text', etc.)

Parameters are passed as 'key=value' pairs, e.g. 'title="My new note"'. See Bear's API documentation for available actions and parameters.

Bearing consists of both an unobtrusive statusbar app and a CLI component. The former will automatically open when the latter is used; it is needed for getting return values from the Bear API.

Examples

Please note: the results below are formatted nicely for better readability, the actual JSON results are not pretty-printed.

Opening a note

/usr/local/bin/bearing \
  open-note \
  --id="123D41D6-E0F1-1234-1234-1B80D08074B7-12345-0000A0958DF5307C"

Returns:

{
  "creationDate": "2020-06-12T07:39:06Z",
  "title": "rtomayko/posix-spawn: Ruby process spawning library",
  "is_trashed": "no",
  "note": "# rtomayko/posix-spawn: Ruby process spawning library\nhttps://github.com/rtomayko/posix-spawn\n\n",
  "identifier": "123D41D6-E0F1-1234-1234-1B80D08074B7-12345-0000A0958DF5307C",
  "modificationDate": "2020-06-12T07:39:06Z",
  "_success": true
}

Creating a note

/usr/local/bin/bearing \
  create \
  --title="Bearing test note" \
  --text="Works for me!"

Returns:

{
  "title": "Bearing test note",
  "identifier": "4963F8B4-3FE0-4835-B96D-7DCCB6101A62-1917-00013DC4BC4EE819",
  "_success": true
}

Searching

/usr/local/bin/bearing
  search \
  --term=macOS \
  --token=ABCDEF-123456-A1B2C3

Returns:

{
  "notes": [
    {
      "creationDate": "2020-06-14T10:09:00Z",
      "title": "Maccy - clipboard manager for macOS",
      "modificationDate": "2020-06-14T10:09:00Z",
      "identifier": "37FA3BEA-E670-1234-1234-9BA2EAB129FF-687-0000004F844AA84B",
      "pin": "no"
    },
    {
      "creationDate": "2020-06-12T07:39:06Z",
      "title": "rtomayko/posix-spawn: Ruby process spawning library",
      "modificationDate": "2020-06-12T07:39:06Z",
      "identifier": "123D41D6-E0F1-1234-1234-1B80D08074B7-12345-0000A0958DF5307C",
      "pin": "no"
    },
    {
      "creationDate": "2020-06-05T09:29:17Z",
      "title": "sbusso/Bear-Power-Pack: A collection of workflows enhancing Bear writer app on iOS and Mac.",
      "modificationDate": "2020-06-11T15:11:07Z",
      "identifier": "310C0689-50D2-1234-1234-F122397F8784-12345-00030C6A48F46C48",
      "pin": "no"
    },
    
  ]
}

Installation

Download a release, unpack it, move Bearing.app to your Applications folder, start it.

Bearing is a menubar app, its icon is a "B". Click the icon, and select "Install /usr/local/bin/bearing" from the menu. This will install a symlink in /usr/local/bin/.

Now you can run bearing from your shell.

Credits

Bearing was made by Carlo Zottmann, https://czm.io/, carlo@zottmann.org.

License

MIT. See LICENSE.md.

Acknowledgements

Bear is a neat piece of software (c) Shiny Frog, Inc. Bearing and its author are neither affiliated nor endorsed by Shiny Frog. I'm just a fan of their stuff.

The Bearing app was made using Platypus, "a developer tool that creates native Mac applications from command line scripts" by Sveinbjörn Þórðarson. Platypus is dope, trust me on that.


app icon

About

Bearing, a scripting helper for Bear, the cuddly macOS notes app.

License:MIT License


Languages

Language:Ruby 92.0%Language:Shell 8.0%