Skip to main content

A CLI tool for terminal clipboard operations

Project description

termcopy

CI

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)

  1. 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
  1. 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
  1. Update and install:
sudo apt update
sudo apt install termcopy

See docs/APT_RELEASE.md for 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:

  1. Detects whether input is coming from a terminal or pipe
  2. Reads from a file argument if input is from terminal, otherwise reads from stdin
  3. Base64 encodes the input data
  4. Removes newlines from the base64 output
  5. 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

  1. Create API tokens on PyPI and TestPyPI
  2. Add the tokens as GitHub secrets:
    • PYPI_API_TOKEN: Your PyPI API token
    • TEST_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:

  1. Run all tests to ensure quality
  2. Calculate the new version based on current version and release type
  3. Update version in pyproject.toml and src/termcopy/__init__.py
  4. Create a GitHub release with the new version tag
  5. Commit and push the version changes
  6. Optionally publish to PyPI/TestPyPI

License

MIT License - see LICENSE file for details.

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

termcopy-0.2.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

termcopy-0.2.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

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

Hashes for termcopy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 400580141b2178c457fc2fc12e9d1a6d90436a51a3d6a680e631616a3e0291bf
MD5 8ce8e636eebdac79c1f31eede4b6b8df
BLAKE2b-256 32b6aec6dfe401659fc6b50f0766c31ad8ab4b92d8f6d4b1208eb4101e6245d4

See more details on using hashes here.

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

Hashes for termcopy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c9852558a5c5b1b19efa09e6904ed14e339077331155112fb76237deeaf13ca
MD5 29524d779b008c330d8d5f588ff6fc89
BLAKE2b-256 52a764fdefed142c523d36eff9642200ed29d5f4c225789172386aef40148561

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