Remove emails from clipboard
A simple shell script that removes email addresses from your clipboard text. Run this before pasting email threads into AI tools such as ChatGPT so that you do not give away personal data. Can be used on macOS or Linux.
Requirements
You need one clipboard tool installed:
| Platform | Clipboard tools supported | Install command |
|---|---|---|
| macOS | pbpaste, pbcopy | (preinstalled) |
| Linux (X11) | xclip or xsel | sudo apt install xclip or sudo apt install xsel |
| Linux (Wayland) | wl-copy, wl-paste | sudo apt install wl-clipboard |
| BSD | xclip or xsel | via package manager |
Installation
git clone https://github.com/ianto-cannon/c...
Remove emails from clipboard
A simple shell script that removes email addresses from your clipboard text. Run this before pasting email threads into AI tools such as ChatGPT so that you do not give away personal data. Can be used on macOS or Linux.
Requirements
You need one clipboard tool installed:
| Platform | Clipboard tools supported | Install command |
|---|---|---|
| macOS | pbpaste, pbcopy | (preinstalled) |
| Linux (X11) | xclip or xsel | sudo apt install xclip or sudo apt install xsel |
| Linux (Wayland) | wl-copy, wl-paste | sudo apt install wl-clipboard |
| BSD | xclip or xsel | via package manager |
Installation
git clone https://github.com/ianto-cannon/clean-clipboard.git
cd clean-clipboard
chmod +x clean-clipboard.sh
sudo mv clean-clipboard.sh /usr/local/bin/clean-clipboard
This makes the script available system-wide as the clean-clipboard command.
Usage
- Copy any text containing one or more email addresses.
- Run:
clean-clipboard
- Paste — all email addresses will have been removed from the clipboard.
Example
Before running clean-clipboard:
From: Alice Johnson <alice.johnson@company.com>
To: Bob Smith <bob.smith@org.net>
Cc: Carol <carol_dev@startup.io>
Subject: Re: Conference Planning
Hi Bob,
Thanks for the update! I’ve attached the draft agenda. Could you ask Carol to confirm the catering details with the venue?
I’ll follow up with the external speakers once we have the finalized schedule.
Best,
Alice
On Tue, 4 Nov 2025 at 10:45, Bob Smith <bob.smith@org.net> wrote:
> Hi Alice,
> Just confirming that the hotel booking is complete. Carol will handle the transport arrangements.
> Best,
> Bob
After running clean-clipboard:
From: Alice Johnson <>
To: Bob Smith <>
Cc: Carol <>
Subject: Re: Conference Planning
Hi Bob,
Thanks for the update! I’ve attached the draft agenda. Could you ask Carol to confirm the catering details with the venue?
I’ll follow up with the external speakers once we have the finalized schedule.
Best,
Alice
On Tue, 4 Nov 2025 at 10:45, Bob Smith <> wrote:
> Hi Alice,
> Just confirming that the hotel booking is complete. Carol will handle the transport arrangements.
> Best,
> Bob
Now the text can be safely pasted into an AI tool without exposing personal email addresses.
Alternative installation: add to your shell
Instead of installing the script as an executable file, you can add the functionality directly to your shell configuration file (~/.bashrc or ~/.zshrc) as a function.
macOS example
Add the following lines to your ~/.zshrc or ~/.bashrc:
clean-clipboard() {
pbpaste | sed -E 's/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}//g' | pbcopy
echo "Email addresses removed from clipboard."
}
Then reload your shell:
source ~/.zshrc # or source ~/.bashrc
You can now run the command directly from your terminal:
clean-clipboard
This will remove all email addresses from your clipboard text on macOS without requiring a separate script file.
License
MIT License