Debian Codegraph @

/

debian golang-github-aymanbagabas-go-osc52 1.2.1-1debian golang-github-aymanbagabas-go-osc52-dev gomod github.com/aymanbagabas/go-osc52 debiangogoinimakefilemarkdownshellyaml 15 files · 121 symbols
View dependency graph

Depends on

README (full)

go-osc52

Latest Release GoDoc

A Go library to work with the ANSI OSC52 terminal sequence.

Example

str := "Hello World!"
osc52.Copy(str) // Copies str to system clipboard
osc52.CopyPrimary(str) // Copies str to primary clipboard (X11 only)

SSH Example

You can use this over SSH using gliderlabs/ssh for instance:

envs := sshSession.Environ()
pty, _, _ := s.Pty()
envs = append(envs, "TERM="+pty.Term)
output := NewOutput(sshSession, envs)
// Copy text in your application
output.Copy("Hello awesome!")

If you're using tmux, you could pass the TMUX environment variable to help detect tmux:

ssh -o SendEnv=TMUX <host>

Tmux users

If you're using tmux, make sure you set set -g default-terminal in your tmux config, to a value that starts with tmux-. tmux-256color for instance. See this for more details.

go-osc52 will wrap the OSC52 sequence in a tmux escape sequence if tmux is detected. If you're running tmux >= 3.3, OSC52 won't work and you'll need to set the set -g allow-passthrough on in your tmux config.

set -g allow-passthrough on

or set set -g set-clipboard on in your tmux config and use your outer terminal in your code instead:

// Assuming this code is running in tmux >= 3.3 in kitty
seq := osc52.Sequence("Hello awesome!", "xterm-kitty", osc52.ClipboardC)
os.Stderr.WriteString(seq)

Credits

dir .github/
dir _examples/
dir debian/
file LICENSE
file README.md
file go.mod
file go.sum
file osc52.go