Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
// Package clipboard read/write on clipboard
package clipboard

import "os"

var isSsh = os.Getenv("SSH_TTY") != ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditioning on SSH seems strange. I see how it narrowly focuses it on your case, but is there a better way to tell OSC-52 should be used?


// ReadAll read string from clipboard
func ReadAll() (string, error) {
return readAll()
}

// WriteAll write string to clipboard
func WriteAll(text string) error {
if isSsh {
return writeOsc52(text)
}
return writeAll(text)
}

Expand Down
8 changes: 8 additions & 0 deletions osc52.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package clipboard

import "os"

func writeOsc52(text string) error {
_, err := os.Stderr.WriteString("\033]52;c;" + text + "\a")
return err
}