()
| 27 | } |
| 28 | |
| 29 | pub fn read_text() -> anyhow::Result<String> { |
| 30 | if cfg!(target_os = "macos") { |
| 31 | return read_with_command("pbpaste", &[]); |
| 32 | } |
| 33 | |
| 34 | if cfg!(target_os = "windows") { |
| 35 | return read_with_command( |
| 36 | "powershell", |
| 37 | &["-NoProfile", "-Command", "Get-Clipboard -Raw"], |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | if std::env::var("WAYLAND_DISPLAY").is_ok() { |
| 42 | if let Ok(text) = read_with_command("wl-paste", &["-n"]) { |
| 43 | return Ok(text); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if let Ok(text) = read_with_command("xclip", &["-selection", "clipboard", "-o"]) { |
| 48 | return Ok(text); |
| 49 | } |
| 50 | |
| 51 | read_with_command("xsel", &["--clipboard", "--output"]) |
| 52 | } |
| 53 | |
| 54 | pub fn write_text(text: &str) -> anyhow::Result<()> { |
| 55 | // Always attempt OSC 52 first — works over SSH when the terminal |
nothing calls this directly
no test coverage detected