Last active
November 23, 2025 05:17
-
-
Save smeech/affa291af51c5bea7a8c1f6d589c0584 to your computer and use it in GitHub Desktop.
[Double capitals] Corrects double-capitals typoed at beginnings of words (Linux & ?WSL) #espanso #regex #sed #python #powershell #bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| - | | |
| excluded = {"VSCodium", "VSCode", "SSHKey", "VMWare"} | |
| print("{{chars}}" if "{{chars}}" in excluded else "{{chars}}".capitalize()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # corrects double-capitals typoed at beginnings of words | |
| # Gets around the lack of "lookaround" in Espanso Rust regex | |
| - regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W) | |
| replace: "{{output}}{{end}}" | |
| vars: | |
| - name: output | |
| type: shell | |
| params: | |
| cmd: | | |
| w="{{chars}}" | |
| case "$w" in | |
| # Exceptions | |
| VSCodium|VSCode|SSHKey|VMWare) | |
| printf '%s' "$w" | |
| ;; | |
| *) | |
| rest="${w:1}" | |
| printf '%s%s' "${w::1}" "${rest,,}" | |
| ;; | |
| esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PowerShell: | |
| - regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W) | |
| replace: "{{output}}{{end}}" | |
| vars: | |
| - name: output | |
| type: shell | |
| params: | |
| shell: pwsh | |
| cmd: ("{{chars}}"[0] + "{{chars}}".Substring(1).ToLower()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment