Skip to content

Instantly share code, notes, and snippets.

@smeech
Last active November 23, 2025 05:17
Show Gist options
  • Select an option

  • Save smeech/40d1624aeece330bb268040d6cdd45cc to your computer and use it in GitHub Desktop.

Select an option

Save smeech/40d1624aeece330bb268040d6cdd45cc to your computer and use it in GitHub Desktop.
[Clipboard manipulation] Espanso clipboard manipulation, to select relevant script line using the choice extension id: parameters. #espanso #bash
# Espanso clipboard manipulation, new version to select relevant script
# line using the choice extension id: parameters.
# To use, copy the text in question and type ":case".
- trigger: :case
label: Modify and paste copied text
replace: '{{Output}}'
vars:
- name: Clipb
type: clipboard
- name: Script_Choice
type: choice
params:
values:
- label: 2. Uppercase
id: bword="{{Clipb}}" ; echo "${bword^^}"
- label: 3. Lowercase
id: bword="{{Clipb}}"; echo "${bword,,}"
- label: 1. Initcase
id: >-
awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1))
tolower(substr($i,2))}1' <<< "{{Clipb}}"
- label: 6. Evaluate equation
id: awk "BEGIN {print {{Clipb}}}"
- label: 4. Word count
id: echo "{{Clipb}}" ; echo "{{Clipb}}" | wc -w
- label: 5. Email
id: thunderbird -compose "to={{Clipb}}"
- name: Output
type: shell
params:
shell: bash
cmd: '{{Script_Choice}}'
# As above, but using Python
- trigger: :case
label: Modify and paste copied text
replace: '{{Output}}'
vars:
- name: Clipb
type: clipboard
- name: Script_Choice
type: choice
params:
values:
- label: 2. Uppercase
id: print("{{Clipb}}".upper())
- label: 3. Lowercase
id: print("{{Clipb}}".lower())
- label: 1. Initcase
id: print(" ".join(w.capitalize() for w in "{{Clipb}}".split()))
- label: 6. Evaluate equation
id: print(eval("{{Clipb}}"))
- label: 4. Word count
id: 't="{{Clipb}}"; print(t); print(len(t.split()))'
- label: 5. Email
id: 'import subprocess; subprocess.run(["thunderbird","-compose",f"to={{Clipb}}"])'
- name: Output
type: script
params:
args: [python, -c, '{{Script_Choice}}']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment