Skip to main content

philiprehberger-clipboard

Tests PyPI version Last updated

Cross-platform clipboard copy and paste in one function call.

Installation

pip install philiprehberger-clipboard

Usage

from philiprehberger_clipboard import copy, paste

copy("Hello, clipboard!")
text = paste()
print(text)  # Hello, clipboard!

Clearing and checking

from philiprehberger_clipboard import clear, copy, equals

copy("secret")
equals("secret")  # True
equals("other")   # False

clear()
equals("")        # True

Detect availability

from philiprehberger_clipboard import copy, is_available

if is_available():
    copy("hello")
else:
    print("install xclip / xsel / wl-clipboard to enable copy")

CLI

Copy text from stdin:

echo "Hello" | python -m philiprehberger_clipboard copy

Paste clipboard contents to stdout:

python -m philiprehberger_clipboard paste

Or use the installed script:

echo "Hello" | clipboard copy
clipboard paste

API

Function Description
copy(text: str) -> None Copy a string to the system clipboard
paste() -> str Read a string from the system clipboard
is_available() -> bool Return True if a clipboard backend is detected on the current platform
clear() -> None Clear the clipboard (equivalent to copy(""))
equals(text: str) -> bool Return True if the clipboard contains exactly text; non-destructive, returns False when backend is unavailable
ClipboardError Raised when clipboard tool is unavailable or operation fails

Platform support

Platform Copy Paste
Windows clip.exe PowerShell Get-Clipboard
macOS pbcopy pbpaste
Linux (X11) xclip or xsel xclip or xsel
Linux (Wayland) wl-copy wl-paste

Development

pip install -e .
python -m pytest tests/ -v

Support

If you find this project useful:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Release files for philiprehberger-clipboard 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for philiprehberger-clipboard 0.3.0
File Size Uploaded
philiprehberger_clipboard-0.3.0.tar.gz 182.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for philiprehberger-clipboard 0.3.0
File Interpreter ABI Platform
philiprehberger_clipboard-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 188.3 kB

Release files / philiprehberger_clipboard-0.3.0.tar.gz

Download URL philiprehberger_clipboard-0.3.0.tar.gz
Size 182.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3e3ac545f8ce7c9bd9143205a20b382cfb61a26025f4f875cbfc76259ad1256c
BLAKE2b-256 checksum
How to use checksums
d6df9714a19803b0bafc74a279af02fc2f7cf39962bb30ba6db241802ff4d62d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / philiprehberger_clipboard-0.3.0-py3-none-any.whl

Download URL philiprehberger_clipboard-0.3.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b323ede95238090025be6543b3e63524ed3e3f17c25454be844e3275bc00f360
BLAKE2b-256 checksum
How to use checksums
1a59e4133e9dcaebbce9ea859c44c12079dc5132b267dd7e9e739c9ea54ac132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page