rewriteText is a lightweight clipboard helper that sends whatever you copy to the Codex CLI, rewrites it with your preferred voice, and drops the polished text back on the clipboard. It is handy for quickly tightening up release notes, status updates, or any other short-form writing without opening an editor.
- Codex CLI installed and logged in. Follow the Codex CLI installation instructions for your platform, then run
codex whoamito confirm authentication before using this script. - Clipboard utilities.
wl-paste/wl-copyon Wayland, orxclipon X11. - GNU userland. A POSIX shell with standard tools (
bash,sed,printf, etc.).
- Clone or download this repository.
- Make the script executable:
chmod +x rewrite.sh. - (Optional) Add it somewhere on your
$PATHor wire it up to a desktop shortcut/launcher.
- Highlight the text you want rewritten and copy it (the script can also fire
Ctrl+Cfor you if one of the auto-copy tools above is available). - Run
./rewrite.shfrom a terminal or launcher. The tool sends the clipboard text throughcodex execand writes the response to a temporary file. - The rewritten text is placed on your clipboard and a confirmation message (plus
notify-sendnotification when available) lets you know it succeeded.
If the clipboard is empty or required tools are missing, the script exits early with a helpful error.
If you are on KDE Plasma, open System Settings → Shortcuts → Custom Shortcuts, add a new command, point it at the absolute path of rewrite.sh, and pick a key combo. On GNOME, use Settings → Keyboard → View and Customize Shortcuts → Custom Shortcuts to add the same command and shortcut. Once bound, highlight any paragraph, press your shortcut, and the script grabs the selection, rewrites it in the voice defined in your style file, and places the result back on the clipboard. You will be notified via a system notification when the request is complete.
- The script reads its rewriting guidance from
writingStyle.md. Edit that file (Markdown works fine even though Codex only sees the text) to describe the tone, structure, and constraints you want. - Prefer to keep your own style file elsewhere? Set
WRITING_STYLE_FILE=/path/to/myStyle.mdbefore running./rewrite.shand that file will be used instead. - Version-control different style files or swap them via launcher scripts if you frequently switch voices (e.g., “status update” vs. “release notes”).