Shell Scripts
Run shell commands and scripts with your selected text.
Basic Shell Script
Shell script actions execute commands in your default shell (typically bash or zsh).
echo '{text}' | tr 'a-z' 'A-Z'
This converts selected text to uppercase.
Using Placeholders
See Placeholders for all available placeholders.
Common Patterns
Transform and copy to clipboard:
echo '{text}' | tr 'a-z' 'A-Z' | pbcopy
Transform and paste back:
echo '{text}' | tr 'a-z' 'A-Z' | pbcopy && {paste}
tip
Instead of using osascript -e 'tell application "System Events" to keystroke "v" using command down', you can simply use {paste} placeholder for a cleaner script!
Examples
Text Transformation
Uppercase:
echo '{text}' | tr 'a-z' 'A-Z' | pbcopy && {paste}
Lowercase:
echo '{text}' | tr 'A-Z' 'a-z' | pbcopy && {paste}
Reverse text:
echo '{text}' | rev | pbcopy && {paste}
Remove whitespace:
echo '{text}' | tr -d ' ' | pbcopy && {paste}
Encoding
Base64 encode:
echo -n '{text}' | base64 | pbcopy && {paste}
URL encode:
python3 -c "import urllib.parse; print(urllib.parse.quote('{text}'))" | pbcopy && {paste}
Developer Tools
Format JSON:
echo '{text}' | python3 -m json.tool | pbcopy
Count words:
echo '{text}' | wc -w | tr -d ' '
Tips
Escaping Special Characters
OnText handles most special characters automatically, but complex scripts may need extra escaping.
Long Scripts
For complex scripts, consider creating a shell script file and calling it:
/path/to/your/script.sh '{text}'