Skip to content

espanso

Created: 2020-04-26 21:54:09 -0700 Modified: 2023-07-03 20:16:58 -0700

This is for text expansions à la AutoHotkey’s hotstrings, e.g. turning “`evs” into “environment variables”.

  • Install (Windows)
  • Set an environment variable for “EDITOR” so that it doesn’t launch with Notepad
    • Open Explorer to Control PanelSystem and SecuritySystem
    • Change Settings
    • Advanced → environment variables
    • Add an “EDITOR” variable with something like C:Program FilesMicrosoft VS CodeCode.exe
  • Editing the configuration:
    • espanso edit
    • Closing the editor should get the changes to “take”, but if you don’t want to close it, just run “espanso restart”.
  • Running matches using keyboard shortcuts
    • This isn’t super important since I can just use Raycast to do what I was trying to do, which is hotkey applications to ⌥1, ⌥2, etc.
  • Running scripts, e.g. typing “‘ref” to write the text “(reference)” and link it to the URL on the clipboard. You can write a shell trigger that runs osascript, but espanso waits for it to finish before deleting the trigger.

I frequently want matches like this:

  • trigger: “‘perm”

replace: “permission”

word: true

propagate_case: true

  • trigger: “‘perms”

replace: “permissions”

word: true

propagate_case: true

On Fri 06/30/2023, I looked into whether I could accomplish this with regex triggers, but it doesn’t seem to be possible, or at least it’s unwieldy. The closest I got was this:

  • regex: “‘perm(?P<plural>[s ])”

replace: “pemission{{plural}}”

word: true

propagate_case: true

  • Typing “‘perm” and a space would work (but you would have to capture all of your delimiters in the regex)
  • Typing “‘perms” would immediately trigger the completion rather than waiting for a space
  • Even if this worked, it’s barely readable to have all of the regex gunk in each trigger
  • “word: true” woes
    • You can’t chain multiple “word: true” triggers easily (reference).
    • The internal buffer tracking whether you’ve typed triggers doesn’t know if you used ⌥Backspace to clear text (reference).