add the paste function for Linux

This commit is contained in:
Cai BingJun 2023-02-03 15:21:11 +08:00
parent 3c636dabe5
commit 9360c11dd1
3 changed files with 133 additions and 222 deletions

View file

@ -40,20 +40,7 @@ pub struct StdinReader {
impl StdinReader {
#[cfg(all(target_os = "linux", feature = "full-repl"))]
fn access_clipboard() -> Option<Output> {
if let Ok(str) = std::fs::read("/proc/sys/kernel/osrelease") {
if let Ok(str) = std::str::from_utf8(&str) {
if str.to_ascii_lowercase().contains("microsoft") {
return Some(
Command::new("powershell")
.args(["get-clipboard"])
.output()
.expect("failed to get clipboard"),
);
}
}
}
Command::new("xsel")
.args(["--output", "--clipboard"])
Command::new("inclip")
.output()
.ok()
}