From 7783fc77ba62673365c60362bb13ef7429751ba3 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Sat, 24 Oct 2020 14:46:38 -0500 Subject: [PATCH] Add support to Zim (#545) --- src/main.rs | 1 + src/steps/os/linux.rs | 5 +---- src/steps/remote/vagrant.rs | 5 +---- src/steps/zsh.rs | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 25086bce..80af7383 100644 --- a/src/main.rs +++ b/src/main.rs @@ -237,6 +237,7 @@ fn run() -> Result<()> { runner.execute(Step::Shell, "antigen", || zsh::run_antigen(&base_dirs, run_type))?; runner.execute(Step::Shell, "zplug", || zsh::run_zplug(&base_dirs, run_type))?; runner.execute(Step::Shell, "zinit", || zsh::run_zinit(&base_dirs, run_type))?; + runner.execute(Step::Shell, "zim", || zsh::run_zim(&base_dirs, run_type))?; runner.execute(Step::Shell, "oh-my-zsh", || zsh::run_oh_my_zsh(&ctx))?; runner.execute(Step::Shell, "fisher", || unix::run_fisher(&base_dirs, run_type))?; runner.execute(Step::Shell, "oh-my-fish", || unix::run_oh_my_fish(&ctx))?; diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 5865cba4..66daf9b4 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -111,10 +111,7 @@ impl Distribution { } pub fn redhat_based(self) -> bool { - match self { - Distribution::CentOS | Distribution::Fedora => true, - _ => false, - } + matches!(self, Distribution::CentOS | Distribution::Fedora) } } diff --git a/src/steps/remote/vagrant.rs b/src/steps/remote/vagrant.rs index 74500d8b..051f84d9 100644 --- a/src/steps/remote/vagrant.rs +++ b/src/steps/remote/vagrant.rs @@ -20,10 +20,7 @@ enum BoxStatus { impl BoxStatus { fn powered_on(self) -> bool { - match self { - BoxStatus::Running => true, - _ => false, - } + matches!(self, BoxStatus::Running) } } diff --git a/src/steps/zsh.rs b/src/steps/zsh.rs index d41e7565..8ab198c7 100644 --- a/src/steps/zsh.rs +++ b/src/steps/zsh.rs @@ -80,6 +80,26 @@ pub fn run_zinit(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { run_type.execute(zsh).args(&["-i", "-c", cmd.as_str()]).check_run() } +pub fn run_zim(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { + let zsh = require("zsh")?; + env::var("ZIM_HOME") + .or_else(|_| { + Command::new("zsh") + .args(&["-c", "[[ -n ${ZIM_HOME} ]] && print -n ${ZIM_HOME}"]) + .check_output() + }) + .map(PathBuf::from) + .unwrap_or_else(|_| base_dirs.home_dir().join(".zim")) + .require()?; + + print_separator("zim"); + + run_type + .execute(zsh) + .args(&["-i", "-c", "zimfw upgrade && zimfw update"]) + .check_run() +} + pub fn run_oh_my_zsh(ctx: &ExecutionContext) -> Result<()> { require("zsh")?; let oh_my_zsh = ctx.base_dirs().home_dir().join(".oh-my-zsh").require()?;