Skip to main content

Python script to copy from STD to your clipboard with OSC 52.

Project description

oscopy

Python tool to copy text to your local clipboard over OSC 52, and record shell command transcripts.

How to Use It

Piping

You simply pipe to oscopy, then paste anywhere:

echo coucou_yopta | oscopy
# now you can paste "coucou_yopta" everywhere

[!IMPORTANT] This works even if you're connected to a remote SSH server. The content travels through SSH and arrives in your local system clipboard.

echo adds a trailing newline. Strip it with -s (or -x):

echo precision | oscopy -s
# now you can paste "precision" knowing it won't add a newline

Why not piping file contents?

cat ~/.ssh/id_rsa.pub | oscopy
# then paste your SSH pubkey on the website...

Record a Command

If you need to execute something and copy both the command you typed and whatever it returned back, e.g.:

$ ls -la
total 112
drwxr-xr-x@ 11 hammerill  staff    352 Mar 10 12:48 .
drwxr-xr-x  12 hammerill  staff    384 Mar  2 11:59 ..
drwxr-xr-x@ 15 hammerill  staff    480 Mar 10 15:36 .git
-rw-r--r--@  1 hammerill  staff    109 Feb  5 09:31 .gitignore
-rw-r--r--@  1 hammerill  staff      5 Feb  5 09:31 .python-version
drwxr-xr-x@  8 hammerill  staff    256 Feb  5 09:31 .venv
-rw-r--r--@  1 hammerill  staff  35149 Feb  5 09:31 LICENSE
-rw-r--r--@  1 hammerill  staff    390 Feb  5 09:31 pyproject.toml
-rw-r--r--@  1 hammerill  staff   1753 Mar 10 13:16 README.md
drwxr-xr-x@  3 hammerill  staff     96 Feb  5 09:31 src
-rw-r--r--@  1 hammerill  staff    127 Feb  5 09:31 uv.lock

...you can use oscopy to do this quickly:

oscopy run ls -la
# now you can paste the thing from above

You can try any other Shell command:

oscopy run -- git status --short

-- is optional, but useful to avoid ambiguity in edge cases with CLI args.

Record a Shell Session

Start a temporary recording shell:

oscopy record
# or `oscopy start`

Session mode currently runs in a temporary zsh shell.

Then run commands normally. When done:

oscopy stop

This copies a transcript like:

$ ls *.md
-rw-r--r--@ 1 hammerill  staff   1.1K Mar 10 12:48 README.md

$ uname -a
Darwin pommier 25.3.0 Darwin Kernel Version 25.3.0 ...

The transcript uses $ as the command prefix, includes both stdout and stderr, and inserts clean blank lines between commands.

Install

Install as a uv tool from PyPi:

uv tool install oscopy

# and, if you have OhMyZsh installed, quickly setup recommended aliases orun, orec and ostop:
oscopy aliases > ~/.oh-my-zsh/custom/oscopy-aliases.zsh

Or install directly from this GitHub repo:

uv tool install git+https://github.com/hammerill/oscopy

Or local dev install:

# in oscopy project folder
uv tool install -e .

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

oscopy-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

oscopy-1.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file oscopy-1.0.1.tar.gz.

File metadata

  • Download URL: oscopy-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oscopy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e10c2d306f3f97d2946909eab075685960409bc2fbbca09b8e8c14518127ec18
MD5 35fccd7447d45f6ae90bbd3a33fdf52d
BLAKE2b-256 62e62e900850a43ce0f85503ad5f51a4b62014e09ed5e075867543ea8361b2c0

See more details on using hashes here.

File details

Details for the file oscopy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: oscopy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oscopy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12bee85aa0b3d23e83d6bf82571b62016383e279af22448352f398fb4a1aff6f
MD5 09fddd7dc7637d2d18c63094948d0b5c
BLAKE2b-256 48d25327f5772fbfa60768d0d54eb304761b6c0709986844df2633a41aa6a9ab

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