| 94 | } |
| 95 | |
| 96 | fn write_osc52(text: &str) { |
| 97 | let encoded = base64::engine::general_purpose::STANDARD.encode(text.as_bytes()); |
| 98 | let osc52 = format!("\x1b]52;c;{encoded}\x07"); |
| 99 | |
| 100 | let sequence = if std::env::var("TMUX").is_ok() || std::env::var("STY").is_ok() { |
| 101 | format!("\x1bPtmux;\x1b{osc52}\x1b\\") |
| 102 | } else { |
| 103 | osc52 |
| 104 | }; |
| 105 | |
| 106 | let _ = std::io::stdout() |
| 107 | .write_all(sequence.as_bytes()) |
| 108 | .and_then(|_| std::io::stdout().flush()); |
| 109 | } |
| 110 | |
| 111 | fn read_with_command(program: &str, args: &[&str]) -> anyhow::Result<String> { |
| 112 | let output = Command::new(program) |