shcopy

command module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 11 Imported by: 0

README

shcopy

Build Status Latest Release

Shell Copy is a simple utility that copies text to the clipboard from anywhere using ANSI OSC52 sequence. It works with local terminals (/dev/tty*) and remote terminals (SSH, Telnet).

Think of this as a tool like xclip or pbcopy but also works over SSH.

Example

# Copy text to clipboard
shcopy "Hello World"

# Copy text to primary clipboard (X11)
shcopy -p "Hello World"

# Copy command output to clipboard
echo -n "Hello World" | shcopy

# Copy file content to clipboard
shcopy < file.txt

# Copy from stdin until EOF
# Ctrl+D to finish
shcopy

# Need help?
shcopy --help

Installation

Go Install
go install github.com/aymanbagabas/shcopy@latest
Homebrew
brew install aymanbagabas/tap/shcopy
Debian/Ubuntu
echo 'deb [trusted=yes] https://repo.aymanbagabas.com/apt/ /' | sudo tee /etc/apt/sources.list.d/aymanbagabas.list
sudo apt update && sudo apt install shcopy
Fedora
echo '[aymanbagabas]
name=Ayman Bagabas
baseurl=https://repo.aymanbagabas.com/yum/
enabled=1
gpgcheck=0' | sudo tee /etc/yum.repos.d/aymanbagabas.repo
sudo yum install shcopy
Arch Linux
yay -S shcopy-bin
Scoop (Windows)
scoop bucket add aymanbagabas https://github.com/aymanbagabas/scoop-bucket.git
scoop install aymanbagabas/shcopy

You can also download the latest binaries and packages from the releases page.

Supported Terminals

This is a non-exhaustive list of the status of popular terminal emulators regarding OSC52 [^1]:

Terminal OSC52 support
Alacritty yes
foot yes
GNOME Terminal (and other VTE-based terminals) not yet
hterm (Chromebook) yes
iTerm2 yes
kitty yes
Konsole not yet
QTerminal not yet
screen yes
st yes (but needs to be enabled, see here)
Terminal.app no, but see workaround
tmux yes
Windows Terminal yes
rxvt yes (to be confirmed)
urxvt yes (with a script, see here)
xterm.js (Hyper terminal) not yet
wezterm yes

[^1]: Originally copied from vim-oscyank

Tmux

To use shcopy within a tmux session, make sure that the outer terminal supports OSC 52, and use one of the following options:

  1. Configure tmux to allow programs to access the clipboard (recommended). The tmux set-clipboard option was added in tmux 1.5 with a default of on; the default was changed to external when external was added in tmux 2.6. Setting set-clipboard to on allows external programs in tmux to access the clipboard. To enable this option, add set -s set-clipboard on to your tmux config.

  2. Use --term tmux option to force shcopy to work with tmux. This option requires the allow-passthrough option to be enabled in tmux. Starting with tmux 3.3a, the allow-passthrough option is no longer enabled by default. This option allows tmux to pass an ANSI escape sequence to the outer terminal by wrapping it in another special tmux escape sequence. This means the --term tmux option won't work unless you're running an older version of tmux or you have enabled allow-passthrough in tmux. Add the following to your tmux config to enable passthrough set -g allow-passthrough on.

Refer to https://github.com/tmux/tmux/wiki/Clipboard for more info.

Credits

This project is built on top of go-osc52, based on vim-oscyank.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL