From 08e8b56b75fd273b0bad17dcec5bb7f1a9b289f5 Mon Sep 17 00:00:00 2001 From: morero <34154552+t4i5uKE@users.noreply.github.com> Date: Sat, 7 May 2022 00:37:28 +0900 Subject: [PATCH] Add: Add new zsh plugin "zi" (#921) --- src/main.rs | 1 + src/steps/zsh.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index 84c7361f..9d290ef9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -267,6 +267,7 @@ fn run() -> Result<()> { runner.execute(Step::Shell, "zgenom", || zsh::run_zgenom(&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, "zi", || zsh::run_zi(&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))?; diff --git a/src/steps/zsh.rs b/src/steps/zsh.rs index 59402ab2..b0d05fc6 100644 --- a/src/steps/zsh.rs +++ b/src/steps/zsh.rs @@ -94,6 +94,21 @@ 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_zi(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { + let zsh = require("zsh")?; + let zshrc = zshrc(base_dirs).require()?; + + env::var("ZPFX") + .map(PathBuf::from) + .unwrap_or_else(|_| base_dirs.home_dir().join(".zi")) + .require()?; + + print_separator("zi"); + + let cmd = format!("source {} && zi self-update && zi update --all", zshrc.display(),); + run_type.execute(zsh).args(["-i", "-c", &cmd]).check_run() +} + pub fn run_zim(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { let zsh = require("zsh")?; env::var("ZIM_HOME")