I am trying to convert one of my zsh function to rust and one of the command involves copy ip address of the machine to clipboard ipconfig getifaddr en0 | pbcopy How do I convert this to rust? I was trying something like this but doesn't seem to work. Also Is there any simpler way than using Command?
Command::new("ipconfig")
.arg("getifaddr")
.arg("en0")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()
.with_context(|| "error in ipconfig subprocess")?;
Command::new("pbcopy")
.stdin(Stdio::piped())
.spawn()
.with_context(|| "error in pbcopy subprocess")?;