Files
topgrade/src/unix.rs

64 lines
1.4 KiB
Rust
Raw Normal View History

2018-06-28 12:16:54 +03:00
use super::utils;
use super::utils::Check;
use failure;
use std::env;
use std::env::home_dir;
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::Command;
pub fn run_zplug(zsh: &PathBuf) -> Result<(), failure::Error> {
Command::new(zsh)
.args(&["-c", "source ~/.zshrc && zplug update"])
.spawn()?
.wait()?
.check()?;
Ok(())
}
2018-07-03 14:31:25 +03:00
pub fn run_fisherman(fish: &PathBuf) -> Result<(), failure::Error> {
Command::new(fish)
.args(&["-c", "fisher update"])
.spawn()?
.wait()?
.check()?;
Ok(())
}
2018-06-28 12:16:54 +03:00
pub fn run_tpm(tpm: &PathBuf) -> Result<(), failure::Error> {
Command::new(&tpm).arg("all").spawn()?.wait()?.check()?;
Ok(())
}
pub fn tpm_path() -> Option<PathBuf> {
let mut path = home_dir().unwrap();
path.push(".tmux/plugins/tpm/bin/update_plugins");
if path.exists() {
Some(path)
} else {
None
}
}
pub fn run_in_tmux() -> ! {
let tmux = utils::which("tmux").expect("Could not find tmux");
let err = Command::new(tmux)
.args(&[
"new-session",
"-s",
"topgrade",
"-n",
"topgrade",
&env::args().collect::<Vec<String>>().join(" "),
";",
"set",
"remain-on-exit",
"on",
])
.exec();
panic!("{:?}", err);
}