Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Espanso - corrects double-capitals typoed at beginnings of words (Linux & ?WSL)
- # Responds to two capitals, followed by two or more lower-case letters (to exclude
- # plurals of short acronyms)
- - regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W)
- replace: "{{output}}{{end}}"
- vars:
- - name: output
- type: shell
- params:
- cmd: sed -E 's/(.)(.*)/\1\L\2/' <<< "{{chars}}"
- # Alternatively:
- - regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W)
- replace: "{{output}}{{end}}"
- vars:
- - name: output
- type: shell
- params:
- cmd: |
- chars="{{chars}}"
- echo "${chars:0:1}$(echo ${chars:1} | tr '[:upper:]' '[:lower:]')"
- # Python:
- - regex: (?P<chars>\b[[:upper:]]{2,}[[:lower:]]{2,})(?P<end>\W)
- replace: "{{output}}{{end}}"
- vars:
- - name: output
- type: script
- params:
- args:
- - python
- - -c
- - print("{{chars}}"[0] + "{{chars}}"[1:].lower())
- # 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())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement