Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buffet/plover_retro_stringop
Call arbitrary code on the last n words!
https://github.com/buffet/plover_retro_stringop
Last synced: 3 months ago
JSON representation
Call arbitrary code on the last n words!
- Host: GitHub
- URL: https://github.com/buffet/plover_retro_stringop
- Owner: buffet
- Created: 2020-11-07T20:33:24.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-09T16:17:37.000Z (7 months ago)
- Last Synced: 2024-09-30T02:37:12.372Z (3 months ago)
- Language: Python
- Size: 1.95 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# plover_retro_stringop
Run arbitrary code on the last n words!
This is inheritly unsafe and horrible, yay!Complaints go to **[[redacted]]@[[redacted]].com**.
### Usage
`{:retro_stringop:N:EXPR}`, where `N` is the number of words (backwards) to work on and `EXPR` is the expression that constitutes the new text.
This has `text` as the entire string and `words` as an array of the individual words (already stripped, use `raw_words` for words including the spaces).`{:retro_stringop_sh:N:EXPR}` does the same stuff, but calls `/bin/sh`, and provides the text as `TEXT` env var.
### Examples
- `{:retro_stringop:1:"(" + text + ")"}`: surround last word in parenthesis
- `{:retro_stringop:2:"(" + text + ")"}`: surround last two words in parenthesis
- `{:retro_stringop_sh:1:echo "$TEXT" | tee some-file.txt}`: log last word to some-file.txt (tee is used here to so that the word doesn't get deleted)
- `{:retro_stringop:1:text[::-1]}`: reverse the last word
- `{:retro_stringop_sh:1:cat "$TEXT"}`: read the last word as a filename, and read that file, replacing the filename with the content
- `{:retro_stringop:3:"".join([w.lower().capitalize() for w in words])}`: PascalCase the last 3 words