Revises text from the clipboard using a Large Language Model.
-
Clone the repository:
git clone https://github.com/yurug/revisor.git cd revisor -
Install dependencies:
python3curl- For X11:
xclip - For Wayland:
wl-pasteandwl-copy - For notification sounds (optional):
paplayoraplay
On Debian/Ubuntu, you can install them with:
sudo apt-get update sudo apt-get install -y python3 curl xclip wl-clipboard libnotify-bin
-
Set up your API key: You need to have an OpenAI API key. Set it as an environment variable:
export OPENAI_API_KEY="your-api-key"
It's recommended to add this line to your shell's startup file (e.g.,
~/.bashrc,~/.zshrc). -
(Optional) Customize the prompt: Create a file at
~/.revisorwith a custom system prompt.If this file doesn't exist, the following default prompt will be used:
Revise the text for clarity and concision. Preserve meaning. Keep same language. Plain text only. -
(Recommended) Install a keyboard shortcut in your environment.
In practice, you should also create a keyboard shortcut to run
revisor.pyfor quick access.For instance, I have added the following line to my
.config/i3/configfile:bindsym $mod+Shift+Control+r exec zsh -lc "~/.local/bin/revisor"(after having created a link to
revisor.pyfrom~/.local/bin/revisor.)
- Copy some text to your clipboard.
- Use your keyboard shorcut or manually run the script:
./revisor.py
- The revised text will be pasted to your clipboard. Paste it!
I've added the following to my .revisor file:
- If you see something between << ... >> remove it from the input but use it as an extension of this prompt.
It happens to be quite handy to give extra instructions specific to your immediate need.
This script follows the KISS principle: it does one specific thing and aims to do it right, with no dependencies and clear semantics. Contributions are welcome as long as they adhere to this philosophy!
MIT License
