Skip to main content

Cross-platform clipboard copy and paste in one function call

Project description

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!

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
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_clipboard-0.1.7.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_clipboard-0.1.7-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_clipboard-0.1.7.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_clipboard-0.1.7.tar.gz
Algorithm Hash digest
SHA256 2e4acb6833e3f3d636e17daa8a37d937475ec9b6a8ba0aa9b870493a3bd29654
MD5 2a794697c815eedc64d3ec3c02692e3c
BLAKE2b-256 b828c2418aad9bc61d89c469cfeea77902434ecf6545cf1fdd547e312ae5e65b

See more details on using hashes here.

File details

Details for the file philiprehberger_clipboard-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_clipboard-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 605a6eb6dbc571f42723b0b97258b18632c09d3a90a50aa99aedc29a3f079562
MD5 98b0633a503979fbea026c3ebdc16030
BLAKE2b-256 e9bad9edfc6c7a9ec8a9a33eb4a4530506cd4ccb5119d3d69f0763a485864b0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page