How to expand text or snippet with the help of HammerSpoon?

466 Views Asked by At

Can we use HammerSpoon to expand text just like aText or TextExpander ?

There is hs.eventtap.keyStrokes("asdf") but how to detect the keystroke and expand the text?

E.g. One use case is to expand mme -> [email protected].

How to achieve this with HammerSpoon ?

1

There are 1 best solutions below

0
ttarchala On

The very nice, open source Spoon (a HammerSpoon plugin/library) called HammerText is the solution here. However, it's not perfect because the solution randomly stops working after some time and nobody knows why - probably a HammerSpoon bug.

https://gist.github.com/maxandersen/d09ebef333b0c7b7f947420e2a7bbbf5#file-init-lua

For good measure, the example you've given does not require HammerText, aText or TextExpander, just plain Mac System Preferences > Keyboard > Text replacement.