From efca67f600936a7e9d0d33e820aa2c674867a789 Mon Sep 17 00:00:00 2001 From: Hugo Haas Date: Sat, 15 Feb 2020 08:11:45 -0600 Subject: [PATCH] Better zinit renaming handling (#321) --- src/steps/zsh.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/steps/zsh.rs b/src/steps/zsh.rs index 48bf4b98..f627bc9e 100644 --- a/src/steps/zsh.rs +++ b/src/steps/zsh.rs @@ -68,14 +68,23 @@ pub fn run_zinit(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(".zinit")) - .require()?; + env::var("ZPFX").map(PathBuf::from).unwrap().require()?; print_separator("zinit"); - let cmd = format!("source {} && zinit self-update && zinit update --all", zshrc.display()); + // Check whether this is a pre- or post- renaming installation + let zcommand = if Path::new(&base_dirs.home_dir().join(".zinit")).exists() { + "zinit" + } else { + "zplugin" + }; + + let cmd = format!( + "source {} && {} self-update && {} update --all", + zshrc.display(), + zcommand, + zcommand + ); run_type.execute(zsh).args(&["-l", "-c", cmd.as_str()]).check_run() }