A CLI tool for terminal clipboard operations
Project description
termcopy
A Python CLI tool for terminal clipboard operations, replicating the functionality of a bash script that sends OSC 52 escape sequences.
Installation
PyPI
pip install termcopy
Debian/Ubuntu via apt
This repo includes Debian packaging metadata and a CI workflow that builds .deb artifacts.
To support:
apt install termcopy
you need a hosted APT repository (e.g., Cloudsmith, Packagecloud, or self-hosted Aptly/reprepro).
User install steps (after repo is published)
- Install repository key (Cloudsmith example):
curl -fsSL https://dl.cloudsmith.io/public/thetranscend/relay/gpg.key \
| sudo gpg --dearmor -o /usr/share/keyrings/termcopy-archive-keyring.gpg
- Add apt source list (Debian bookworm):
echo "deb [signed-by=/usr/share/keyrings/termcopy-archive-keyring.gpg] https://dl.cloudsmith.io/public/thetranscend/relay/deb/debian bookworm main" \
| sudo tee /etc/apt/sources.list.d/termcopy.list
- Update and install:
sudo apt update
sudo apt install termcopy
See
docs/APT_RELEASE.mdfor maintainer-side publishing steps.
Usage
The tool reads input from either a file or stdin, base64 encodes it, and outputs an OSC 52 escape sequence for clipboard operations.
From a file:
termcopy filename.txt
From stdin:
echo "Hello, World!" | termcopy
From a pipe:
cat somefile.txt | termcopy
How it works
The tool:
- Detects whether input is coming from a terminal or pipe
- Reads from a file argument if input is from terminal, otherwise reads from stdin
- Base64 encodes the input data
- Removes newlines from the base64 output
- Wraps the result in an OSC 52 escape sequence for clipboard operations
Development
To install in development mode:
pip install -e .
To install with development dependencies:
pip install -e ".[dev]"
Running tests
pytest tests/ -v
Code formatting and linting
# Format code
black src/ tests/
# Check code style
flake8 src/ tests/
# Type checking
mypy src/
CI/CD
This project uses GitHub Actions for continuous integration and deployment:
-
Test workflow (
.github/workflows/test.yml): Runs on every push and pull request- Tests against Python 3.8-3.12
- Runs linting (black, flake8, mypy)
- Uploads coverage reports
-
Publish workflow (
.github/workflows/publish.yml): Runs on version tags- Builds and publishes to PyPI
- Also publishes to TestPyPI
-
Manual release workflow (
.github/workflows/release.yml): Can be triggered manually- Allows custom version releases
- Optional publishing to PyPI/TestPyPI
-
Auto release workflow (
.github/workflows/auto-release.yml): Automated version incrementing- Automatically calculates next version (patch/minor/major)
- Creates GitHub releases with tags
- Updates version files and commits changes
- Optional publishing to PyPI/TestPyPI
Setting up PyPI publishing
- Create API tokens on PyPI and TestPyPI
- Add the tokens as GitHub secrets:
PYPI_API_TOKEN: Your PyPI API tokenTEST_PYPI_API_TOKEN: Your TestPyPI API token
Automated Releases
The auto-release workflow provides three release types:
- Patch (0.1.0 → 0.1.1): Bug fixes and minor improvements
- Minor (0.1.0 → 0.2.0): New features, backward compatible
- Major (0.1.0 → 1.0.0): Breaking changes
The workflow will:
- Run all tests to ensure quality
- Calculate the new version based on current version and release type
- Update version in
pyproject.tomlandsrc/termcopy/__init__.py - Create a GitHub release with the new version tag
- Commit and push the version changes
- Optionally publish to PyPI/TestPyPI
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file termcopy-0.2.1.tar.gz.
File metadata
- Download URL: termcopy-0.2.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
400580141b2178c457fc2fc12e9d1a6d90436a51a3d6a680e631616a3e0291bf
|
|
| MD5 |
8ce8e636eebdac79c1f31eede4b6b8df
|
|
| BLAKE2b-256 |
32b6aec6dfe401659fc6b50f0766c31ad8ab4b92d8f6d4b1208eb4101e6245d4
|
File details
Details for the file termcopy-0.2.1-py3-none-any.whl.
File metadata
- Download URL: termcopy-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c9852558a5c5b1b19efa09e6904ed14e339077331155112fb76237deeaf13ca
|
|
| MD5 |
29524d779b008c330d8d5f588ff6fc89
|
|
| BLAKE2b-256 |
52a764fdefed142c523d36eff9642200ed29d5f4c225789172386aef40148561
|