2018-07-07 09:18:53 +03:00
|
|
|
use super::utils::{which, Check, PathExt};
|
|
|
|
|
use directories::BaseDirs;
|
2018-06-28 12:16:54 +03:00
|
|
|
use failure;
|
|
|
|
|
use std::env;
|
|
|
|
|
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(())
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-07 09:18:53 +03:00
|
|
|
pub fn tpm_path(base_dirs: &BaseDirs) -> Option<PathBuf> {
|
|
|
|
|
base_dirs
|
|
|
|
|
.home_dir()
|
|
|
|
|
.join(".tmux/plugins/tpm/bin/update_plugins")
|
|
|
|
|
.if_exists()
|
2018-06-28 12:16:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn run_in_tmux() -> ! {
|
2018-07-07 09:18:53 +03:00
|
|
|
let tmux = which("tmux").expect("Could not find tmux");
|
2018-06-28 12:16:54 +03:00
|
|
|
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);
|
|
|
|
|
}
|