Skip to content

Instantly share code, notes, and snippets.

@regendo
Last active July 27, 2020 08:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regendo/742e10df9d1f4cc58e8033ef5b5a27de to your computer and use it in GitHub Desktop.
Save regendo/742e10df9d1f4cc58e8033ef5b5a27de to your computer and use it in GitHub Desktop.
Bear config file for espanso. Put it into `~/Library/Preferences/espanso/user`. Requires urlencode: https://github.com/dead10ck/urlencode
name: bear
parent: default
matches:
# Footer
- trigger: ":bfoot"
# Multi-Line string that keeps newlines and adds one at the end.
# Syntax highlighters might interpret the markdown headings as YAML comments, like this one. This is incorrect; YAML understands that these are part of the multi-line string data.
replace: |
---
## Metadata
Created on {{timestamp}}.
### What links here?
References to [{{clipboard}}](bear://x-callback-url/search?term={{urlencode}})
### Additional References
### Additional Tags
vars:
- name: timestamp
type: date
params:
format: "[[%B %d, %Y]] (%A) at %I:%M %p"
- name: clipboard
type: clipboard
- name: urlencode
type: shell
params:
cmd: echo '"'$(pbpaste)'"' | $HOME/.cargo/bin/urlencode
trim: true
# Search Link
- trigger: :blink
replace: "[{{clipboard}}](bear://x-callback-url/search?term={{urlencode}})"
vars:
- name: clipboard
type: clipboard
- name: urlencode
type: shell
params:
cmd: echo '"'$(pbpaste)'"' | $HOME/.cargo/bin/urlencode
trim: true
- trigger: ":bdate"
# Because each bear note already starts with the `#` H1 tag, we omit it from the title.
replace: |-
{{title}}
---
## Metadata
### What links here?
References to [{{title}}](bear://x-callback-url/search?term={{urlencode}})
### Additional References
### Additional Tags
#journal/daily
vars:
- name: title
type: date
params:
format: "%B %d, %Y"
- name: urlencode
type: shell
params:
cmd: date +"%B %d, %Y" | $HOME/.cargo/bin/urlencode
trim: true
@regendo
Copy link
Author

regendo commented Jul 21, 2020

Workflow:

  1. Copy a note's title into your clipboard.
  2. Type the completion command :blink to create a "what links here" style backlink at the cursor's location, or type :bfoot to create a whole footer, including that link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment