diff options
Diffstat (limited to 'src/commands/file_ops.rs')
-rw-r--r-- | src/commands/file_ops.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/commands/file_ops.rs b/src/commands/file_ops.rs index e9d889a..f289323 100644 --- a/src/commands/file_ops.rs +++ b/src/commands/file_ops.rs @@ -1,5 +1,5 @@ use std::io; -use std::process::Command; +use std::process::{Command, Stdio}; use crate::context::{AppContext, LocalStateContext}; use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult}; @@ -129,27 +129,27 @@ fn copy_string_to_buffer(string: String) -> JoshutoResult { let clipboards = [ ( "wl-copy", - format!("printf '%s' '{}' | {} 2> /dev/null", string, "wl-copy"), - ), - ( - "xsel", - format!("printf '%s' '{}' | {} -ib 2> /dev/null", string, "xsel"), - ), - ( - "pbcopy", - format!("printf '%s' '{}' | {} 2> /dev/null", string, "pbcopy"), + format!("printf '%s' '{}' | {}", string, "wl-copy"), ), + ("xsel", format!("printf '%s' '{}' | {} -ib", string, "xsel")), + ("pbcopy", format!("printf '%s' '{}' | {}", string, "pbcopy")), ( "xclip", format!( - "printf '%s' '{}' | {} -selection clipboard 2> /dev/null", + "printf '%s' '{}' | {} -selection clipboard", string, "xclip" ), ), ]; - for (_, command) in clipboards.iter() { - match Command::new("sh").args(["-c", command.as_str()]).status() { + for (_, cmd) in clipboards.iter() { + let status = Command::new("sh") + .args(["-c", cmd.as_str()]) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status(); + + match status { Ok(s) if s.success() => return Ok(()), _ => {} } |