Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@smeech
smeech / heredoc.yml
Last active March 13, 2025 17:55
[HereDoc] Capture clipboard content, preserving quote characters contained, by using the Here-Document method #espanso #bash #sed
# Capture and process clipboard content, preserving quote characters contained,
# by using the Here-Document method.
- trigger: ":dwq"
replace: "{{MyShell}}"
vars:
- name: Clipb
type: clipboard
- name: MyShell
type: shell
@smeech
smeech / espanso_search
Last active February 4, 2025 14:16
[Espanso Search] Scripts to find and list Espanso trigger/regex values. #espanso #bash #python #pwsh
@smeech
smeech / trigger_espanso.py
Last active February 4, 2025 19:04
[Trigger] A Python script to invoke `espanso match exec -t (trigger)`, which gets around Espanso trying to delete the trigger characters (which don't exist when called in this manner) by injecting the characters first. An alternative to using: `xdotool sleep 0.2 type (trigger)`. Either can be attached to a system hotkey. #espanso #python
# A Python script to invoke `espanso match exec -t <trigger>`, which gets around
# Espanso trying to delete the trigger characters (which don't exist when called
# in this manner) by injecting the characters first.
# An alternative to using: `xdotool sleep 0.2 type <trigger>`
# Either can be attached to a system hotkey.
#!/usr/bin/env python3
import subprocess, sys, time
from pynput.keyboard import Controller, Key
@smeech
smeech / speed.yml
Created January 31, 2025 17:23
[Speed test] between shell: and script: #espanso #powershell
# Espanso speed test between shell: and script
# No discernible difference here on Linux, but recommend using script: to avoid calling
# an unnecessary process
# Conversation at https://discord.com/channels/884163483409731584/1013916990760554608/1253033704599846973
global_vars:
- name: code
type: echo
params:
echo: |
@smeech
smeech / popup.yml
Last active February 4, 2025 22:13
[Popup date selector] #espanso #python
# Espanso popup date selector
- trigger: :ddate
replace: '{{output}}'
vars:
- name: output
type: script
params:
args:
- python
@smeech
smeech / genpass.yml
Last active January 31, 2025 17:32
[Password generator] A simple password generator written while reflecting on an Espanso Hub submission. Called by `:genpass()` for a twelve-character password, or `:genpass(n)` for an n-length password. #espanso #python #regex
# A simple password generator written while reflecting on an Espanso Hub submission
# Called by `:genpass()` for a twelve-character password, or
# `:genpass(n)` for an n-length password.
# The script will add the result to the clipboard for pasting elsewhere,
# if `pyperclip` is installed
matches:
- regex: :genpass\((?P<myvar>\d*)\)
replace: "{{output}}"
vars:
@smeech
smeech / monitor_log.sh
Created January 31, 2025 17:05
[Monitor Espanso log] Continuously without repeated typing of `espanso log`. #espanso #bash #powershell
# Routines to follow the Espanso log for problems, without having to
# type `espanso log` every time something goes wrong.
# Filters out routine messages.
# Linux
tail -F ~/.cache/espanso/espanso.log | grep -v "INFO"
# Windows
Get-Content "$env:LOCALAPPDATA\espanso\espanso.log" -Wait | Where-Object { $_ -notmatch "INFO" }
@smeech
smeech / variables.yml
Last active January 31, 2025 17:02
[Minimised variables] A compact way of listing multiple variables for e.g. a list form. #espanso
# Espanso minimised variables used in a list Form
# https://onlineyamltools.com/minify-yaml is helpful
- trigger: :td1
replace: "{{Output.Date}}"
vars:
- {name: Day, type: date, params: {format: '%d'}}
- {name: Month, type: date, params: {format: '%m'}}
- {name: Year2, type: date, params: {format: '%y'}}
- {name: Year4, type: date, params: {format: '%Y'}}
@smeech
smeech / URL_extract.yml
Created January 31, 2025 16:54
[Text URL extract] Extract text and URL from copied web-page link. #espanso #python
- trigger: :test
replace: '{{Clipb}} {{Output}}'
vars:
- name: Clipb
type: clipboard
- name: Output
type: script
params:
args:
- python
@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