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

pip install termcopy

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.0.tar.gz (6.4 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.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file termcopy-0.2.0.tar.gz.

File metadata

  • Download URL: termcopy-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for termcopy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 99f7715955025f1869bc206edf9b034d99b9a69cf3ee6b3d5b0bebd2d34578f8
MD5 daadfebfc197cc8727517f912bc6c3a4
BLAKE2b-256 910c720f62539d76c3bf38223c42436f044946525e6e719331a1f1a8e6220142

See more details on using hashes here.

File details

Details for the file termcopy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: termcopy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for termcopy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26bc3b52d8e734a6770830f7044c7fbd5f9bf2d3bc5d8c65b8484dfb4d4cda13
MD5 e258aaff974bb068f167739e792aea88
BLAKE2b-256 c1e15294ed9be5120270541f4140ddcd9608cd0464a357327019a12d9bed24cf

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