Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@smeech
smeech / temp.yml
Last active February 18, 2025 15:07
[Temperature C/°F conversion] Espanso temperature C/°F conversion. From conversation at: https://discord.com/channels/884163483409731584/1013914627886817372/1253000300730515508. Usage: ::10C → 10C / 50.00°F or ::10F → 10°F / -12.22C #espanso #python #regex
# Espanso temperature C/°F conversion
# From conversation at: https://discord.com/channels/884163483409731584/1013914627886817372/1253000300730515508
# Usage: ::10C → 10C / 50.00°F, or ::10F → 10°F / -12.22C
matches:
- regex: ::(?P<value>\d+(?:\.\d+)?)(?P<unit>[CF])
replace: "{{output}}"
vars:
- name: output
type: script
params:
@smeech
smeech / brackets.yml
Last active January 31, 2025 15:53
[Autocomplete brackets] Espanso trigger to autocomplete brackets etc. at the end of a string, on typing double-space. It will fall over if there's a single-quote within the string, however. #espanso #python #regex
# Espanso trigger to autocomplete brackets etc. at the end of a string, on typing double-space.
# It will fall over if there's a single-quote within the string, however.
matches:
- regex: '(?P<delim>[\[\(\{<"])(?P<string>.+) '
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
@smeech
smeech / choices.yml
Last active April 27, 2025 21:52
[Second choice conditional on first choice] The trigger, `:test` invokes the first "select" choice box which supplies the options for the second "output" choice variable. Rewritten from the previous version which relied on writing files. The technique is not possible using verbose syntax, so cannot be combined with a "layout:" field. #espanso
matches:
- trigger: :test
replace: "{{output}}"
vars:
- name: select
type: choice
params:
values:
- label: One
id: |
@smeech
smeech / file.yml
Last active March 5, 2025 23:08
[Input from file] Trigger to read input from a file. #espanso #bash
# Trigger to read input from a file
matches:
- trigger: :test
replace: "{{output}}"
vars:
- name: output
type: shell
params:
# cmd: echo $(</home/$USER/temp/br.txt) # Strips out newlines
cmd: cat /home/$USER/temp/br.txt
@smeech
smeech / ascii.yml
Last active January 31, 2025 17:36
[ASCII character triggers] #espanso
# ASCII character triggers
# https://donsnotes.com/tech/charsets/ascii.html
matches:
- trigger: "\x05" # <ctrl-e>
replace: testing
@smeech
smeech / parse_help.py
Last active January 31, 2025 16:13
[Parse Help] Espanso: Parse entirety of `espanso --help` recursively #espanso #python
#!/usr/bin/env python3
# A script to parse `espanso --help` recursively throughout all its levels.
import subprocess
import sys
def parse_help(command):
try:
help_text = subprocess.check_output(command + ['--help'], stderr=subprocess.STDOUT, text=True)
except subprocess.CalledProcessError as e:
@smeech
smeech / help.txt
Last active January 31, 2025 16:12
[Entirety of Espanso help text] #espanso
espanso 2.2.1
Federico Terzi
A Privacy-first, Cross-platform Text Expander
USAGE:
espanso [FLAGS] [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-v Sets the level of verbosity
@smeech
smeech / caps.yml
Last active September 8, 2025 18:06
[Double capitals] Corrects double-capitals typoed at beginnings of words (Linux & ?WSL) #espanso #regex #sed #python #powershell #bash
# corrects double-capitals typoed at beginnings of words
- regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W)
replace: "{{output}}{{end}}"
vars:
- name: output
type: script
params:
args:
- python
- -c
@smeech
smeech / ord.yml
Last active January 31, 2025 16:01
[Ordinal suffixes] Superscript suffixes of ordinal numbers with some checking for validity. #espanso #regex
# Espanso superscript suffixes of ordinal numbers with some checking for validity
matches:
- regex: (?P<number>\s[1]|[0,2-9]1)st
replace: "{{number}}ˢᵗ"
- regex: (?P<number>\s[2]|[0,2-9]2)nd
replace: "{{number}}ⁿᵈ"
- regex: (?P<number>\s[3]|[0,2-9]3)rd
replace: "{{number}}ʳᵈ"
- regex: (?P<number>\s[0,4-9]|[1][\d]|[0,2-9][0,4-9])th
replace: "{{number}}ᵗʰ"
@smeech
smeech / capital.yml
Last active August 15, 2025 22:04
[Sentence capitalise] Capitalise new sentence after period, question or exclamation mark. #espanso #regex #bash #python
# Capitalises first letter after sentence-ending punctuation, skipping exceptions
- regex: (?P<before>\b[\w.]+[.?!])\s(?P<firstchar>[a-z])(?P<therest>\w*\W)
replace: "{{before}} {{capital}}{{therest}}"
vars:
- name: capital
type: script
params:
args:
- python
- -c