A Python CLI tool for terminal clipboard operations, replicating the functionality of a bash script that sends OSC 52 escape sequences.
pip install termcopyThis repo includes Debian packaging metadata and a CI workflow that builds .deb artifacts and publishes to Cloudsmith on v* tags.
Official Cloudsmith setup/install flow:
curl -1sLf 'https://dl.cloudsmith.io/public/thetranscend/relay/setup.deb.sh' | sudo -E bash
sudo apt-get update
sudo apt-get install termcopyInstall a specific version (example):
sudo apt-get install termcopy=0.2.1-1If you manage apt sources manually:
curl -fsSL https://dl.cloudsmith.io/public/thetranscend/relay/gpg.key \
| sudo gpg --dearmor -o /usr/share/keyrings/termcopy-archive-keyring.gpg
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
sudo apt update
sudo apt install termcopySee
docs/APT_RELEASE.mdfor maintainer-side publishing steps.
After publishing a new tag (vX.Y.Z):
- Confirm Debian workflow succeeded and uploaded
.debartifact. - Verify package is visible in Cloudsmith for
thetranscend/relay. - Test install in a clean Debian container/VM:
- add repo
apt updateapt install termcopy
- Smoke-test command:
echo "hello" | termcopyThe tool reads input from either a file or stdin, base64 encodes it, and outputs an OSC 52 escape sequence for clipboard operations.
termcopy filename.txtecho "Hello, World!" | termcopycat somefile.txt | termcopyThe 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
To install in development mode:
pip install -e .To install with development dependencies:
pip install -e ".[dev]"pytest tests/ -v# Format code
black src/ tests/
# Check code style
flake8 src/ tests/
# Type checking
mypy src/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
- 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
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
MIT License - see LICENSE file for details.