Clipboard Regex Replace is a lightweight application that allows you to automatically apply regex-based replacements to your clipboard content using a customizable hotkey. The application is currently only tested on Windows, but might also work on Linux and Mac.
This application can be used to obfuscate names, personal data or directories from content pasted to LLMs automatically.
- Apply multiple regex replacements to clipboard content
- Customizable keyboard shortcut
- System tray icon for easy access and management
- Configurable via a JSON file
- Custom icon support
- Optional desktop notifications
- Python 3.6+
conda create -y -n clipboard_regex_env
conda activate clipboard_regex_env
- Clone this repository or download the source code.
- Install the required Python packages:
pip install keyboard pyperclip pystray pillow
-
Copy the
config.json.example
file toconfig.json
and modify it according to your needs. -
(Optional) If you want to use desktop notifications, install the
plyer
package:
pip install plyer
The config.json
file allows you to customize the behavior of the application. Here's an example configuration:
{
"hotkey": "ctrl+alt+v",
"icon_path": "path/to/your/icon.png",
"use_notifications": true,
"replacements": [
{
"regex": "(?i)name[s]?[/\\\\]?",
"replace_with": ""
},
{
"regex": "example_pattern",
"replace_with": "example_replacement"
}
]
}
hotkey
: The keyboard shortcut to trigger the replacement (default: "ctrl+alt+v")icon_path
: Path to a custom icon file (PNG format recommended)use_notifications
: Set totrue
to enable desktop notifications (requiresplyer
package)replacements
: An array of regex replacement rulesregex
: The regex pattern to matchreplace_with
: The string to replace the matched pattern with
- Run the
clipboard_regex_replace.py
script:
python clipboard_regex_replace.py
- The application will start and show an icon in the system tray.
- Copy some text to your clipboard.
- Press the configured hotkey (default: Ctrl+Alt+V).
- The application will apply all configured regex replacements to the clipboard content and automatically paste the result.
- If notifications are enabled, you'll see a desktop notification confirming the replacement.
- Create a shortcut to the
StartClipboard.bat
file. - Press Win+R, type
shell:startup
, and press Enter. - Move the created shortcut to the Startup folder that opens.
The application logs its activities to clipboard_regex_replace.log
in the same directory as the script. Check this file if you encounter any issues.
This project is licensed under the MIT License - see the LICENSE file for details.