Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@smeech
smeech / swap.yml
Last active February 17, 2025 22:11
[Swap outputs] The following snippet produces a choice Form and then uses a shell or Python script to swap its input for different values. It's an alternative to label: & id: use, that enables the use of the choice: drop-down facility #espanso #bash #python
# The following snippet produces a choice Form and then uses
# a shell script to swap its input for different values.
# It's an alternative to label: & id: use, that
# enables the use of the choice: drop-down facility
- trigger: :test
replace: "{{output}}"
vars:
- name: form1
type: form
@smeech
smeech / my_spellings.yml
Last active January 7, 2026 23:20
[My spellings] Trigger to add corrected spellings to my_spellings.yml. Copy incorrect and correct words and type ":spell". #espanso #spelling #bash
# Release schema for VSCode/VSCodium/Vim
# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/match.schema.json
matches:
# Trigger to add corrected spellings to my_spellings.yml
# Copy the incorrect and correct words, separated by a space, and type ":spell"
- trigger: :spell
replace: "{{Output}}"
@smeech
smeech / contractions.py
Created January 31, 2025 16:14
[Contractions] Export smallest unique contractions of a list of words for Espanso #espanso #python
# Export smallest unique contractions of a list of words for Espanso
from collections import defaultdict
def shortest_unique_component(word, words_count):
if words_count is None:
return None
for i in range(len(word)):
contraction = word[:i+1]
@smeech
smeech / assessment.yml
Created January 31, 2025 16:17
[Psychological assessment] Espanso draft form and output for Bswizzles #espanso
# Espanso draft form and output for Bswizzles
- trigger: /mse
replace: >
Client presented as age {{form1.age}} and was {{form1.alert}}.
Client was {{form1.calm}} and {{form1.attended}} to the interview.
Client was dressed in {{form1.clothing}} clothing appropriate for the
setting with {{form1.hygiene}} as though {{form1.not1}} regularly
attending to ADLs.
Eye contact was {{form1.wnl}}. Speech was {{form1.rtv}}.
Client reported mood as {{form1.mood}}.
@smeech
smeech / caseinsens.yml
Created January 31, 2025 16:26
[Case insensitive + word: true] A case-insensitive trigger expansion with word: true functionality. Triggered by "example ????", "EXAMPLE ?????", "exaMPLe ????" etc. #espanso #regex
# A case-insensitive trigger expansion with word: true functionality.
# Triggered by "example ????", "EXAMPLE ?????", "exaMPLe ????" etc.:
- regex: (?i)\bexample(?P<w>\W)
replace: Something{{w}}
@smeech
smeech / ConvertMarkdown.ps1
Created January 31, 2025 16:31
[Convert markdown] Script to convert Markdown to Plain text, using an Espanso trigger. #espanso #powershell #python
## Script to convert Markdown to Plain text, using an Espanso trigger:
#!/usr/bin/env pwsh
param (
[string]$markdownText
)
# Function to convert Markdown to plain text
function Convert-MarkdownToText {
@smeech
smeech / default.yml
Created January 31, 2025 16:34
[default.yml] Default Espanso configuration file #espanso
# espanso configuration file
# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/config.schema.json
# For a complete introduction, visit the official docs at: https://espanso.org/docs/
# You can use this file to define the global configuration options for espanso.
# These are the parameters that will be used by default on every application,
# but you can also override them on a per-application basis.
@smeech
smeech / delays-characters.yml
Last active November 12, 2025 10:55
[Delays in replacements] Espanso doesn't support replacements which include delays. A solution is to ignore Espanso's own replace and use another tool to inject characters. Similar methods are available for Windows PowerShell using e.g.: (New-Object -ComObject wscript.shell).SendKeys #espanso #python
# Espanso trigger to be used in conjunction with the script test_pynput.py
# Uses the Python pynput library to inject text, instead of Espanso. Enables the
# addition of pauses (sleep) and <Tab> etc. keys and can include Espanso {{variables}}
# See https://pynput.readthedocs.io/en/latest/keyboard.html#controlling-the-keyboard
# Supports type, tap, press, release, and sleep
# Whilst you can add to the replace:, anything there will be injected AFTER the script's
# output
- trigger: :delay
replace: '{{output}}'
@smeech
smeech / delays.yml
Last active May 25, 2026 20:51
[Delays] Espanso doesn't support replacements which include delays. A couple of alternatives. #espanso #bash #python
# Espanso doesn't support replacements which include delays
# A solution is to ignore Espanso's own replace and use another tool to inject characters
# Similar methods are available for Windows PowerShell using e.g.:
# (New-Object -ComObject wscript.shell).SendKeys
# Snippet to inject text using xdotool
- trigger: ":xd"
replace: "{{output}}"
vars:
- name: output
@smeech
smeech / espanso_move.sh
Last active January 31, 2025 16:51
[Espanso move] Espanso doesn't facilitate repositioning of its Search or Choice etc. windows. This background script waits and moves its windows. #espanso #bash
#!/bin/bash
# A slightly more efficient version of espanso_move.sh which utilises xwininfo.
# Espanso doesn't facilitate repositioning of its Search or Choice etc. windows.
# If the following script is running in the background, it will await the opening
# of the window, and move it to the top left of the screen.
# Adjust the middle two coordinates (,0,0,) for a different position, and reduce
# the lower sleep value (included to reduce CPU load) if it's too slow