Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@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 / 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 / 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 / date_time.yml
Last active October 13, 2025 09:49
[Date_Time] Espanso trigger to output time and date in another timezone. Requires Python and its pytz library. Somewhat redundant from Espanso v2.3.0. #espanso #python
# Espanso trigger to output time and date in another timezone
# Requires Python and its pytz library
matches:
- trigger: :tzdate
replace: '{{output}}'
vars:
- name: zones
type: script
params:
@smeech
smeech / oasis.yml
Last active January 10, 2025 14:17
[OASIS-IS] My take on https://github.com/espanso/hub/pull/123 #espanso
# yaml-language-server: https://github.com/espanso/espanso/blob/dev/schemas/match.schema.json
# OASIS-IS ChatGPT framework Form. OASIS-IS stands for : O-bjective, A-rchtype, -S-etting, I-llustrations, S-tyle, - , I-nterpretation, S-pecification.
# After those steps are Evalute - How good was the response, give your chatbot feedback, and then Banter - Continue the conversation.
# Paid ChatGPT users can use the current list of models avaialble while unpaid can use the default model.
# The frameworks spreadsheet can be found here: http://3dmkf.com/pace-oasis
# This first one, is meant to generate a prompt. Run :oasis from a URL in a web browser, fill out the form and submit it, then press enter. It wiss pass the prompt to ChatGPT.
global_vars:
@smeech
smeech / offset_date_bash.yml
Last active June 26, 2025 19:14
[Date offsets] Espanso snippets to return offset date from today - various versions. #espanso #python #powershell #bash #regex #javascript #ruby
# Espanso snippets to return offset date from today
# It was pointed out that my v1 didn't allow for different length months and years.
# Thanks to @StewCam on Discord https://discord.com/channels/884163483409731584/1013914627886817372/1251704970080944189
# Here are five updated versions which do.
# Pick one and type e.g.: +2w, -3m etc.
# Bash version for Linux. For macOS Bash or Zsh see the discussion below
- regex: (?P<Offset>[+-]\d+)(?P<Unit>[dwmy])
replace: "{{Output}}"
label: Bash Offset date
@smeech
smeech / osvar.yml
Last active January 31, 2025 16:08
[OSVar] OS-independent variable setting #espanso #python
# Set an Espanso global variable for the system "HOME" directory, regardless of OS
# to avoid the need to use `filter_os:`, as Espanso can only use ONE app-specific
# configuration at a time.
# Requires Python
global_vars:
- name: home
type: script
params:
args: [python, -c, print(__import__('os').path.expanduser('~'))]
@smeech
smeech / backend.yml
Last active January 31, 2025 16:09
[Injection methods] Tests for Espanso clipboard & inject (keys) injection methods #espanso
matches:
- trigger: :testclip
replace: something
force_mode: clipboard
# If this one works, you'll probably need an app-specific configuration
# for the filter_class:, _exec: or _title: (in that order of preference)
# specifying "backend: clipboard"
- trigger: :testinject
@smeech
smeech / espanso_add.py
Last active August 2, 2025 22:12
[Espanso add] Python script to add Espanso `trigger:`/`replace:` pairs, checking for duplicate triggers #espanso
# Python script to add Espanso trigger:/replace: pairs
# Usage: python espanso_add.py <trigger> <replace> [filename]
import subprocess
import sys
import os
def append_to_file(trigger, replace, filename):
# Set default filename if not provided
if not filename:
@smeech
smeech / ftext.yml
Last active May 3, 2025 21:10
[Add text from file] #espanso #python
# From https://github.com/espanso/espanso/discussions/1908
matches:
- trigger: :test
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
- python