From 03d7a4bce4d7940c49bfbfed4435aee8a9c1b144 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 8 Jul 2016 20:43:53 +0100 Subject: [PATCH] Move all cd commands into sub commands This is to stop the user's CWD being changed --- zsh-nvm.plugin.zsh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index 681ab26..24ecdde 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -22,22 +22,19 @@ _zsh_nvm_latest_release_tag() { _zsh_nvm_install() { git clone https://github.com/creationix/nvm.git "$NVM_DIR" - cd "$NVM_DIR" - git checkout --quiet "$(_zsh_nvm_latest_release_tag)" + $(cd "$NVM_DIR" && git checkout --quiet "$(_zsh_nvm_latest_release_tag)") } nvm_update() { - cd "$NVM_DIR" echo "Checking latest version of nvm..." - local installed_version=$(git describe --tags) + local installed_version=$(cd "$NVM_DIR" && git describe --tags) local latest_version=$(_zsh_nvm_latest_release_tag) echo "Installed version is $installed_version" if [[ "$installed_version" = "$latest_version" ]]; then echo "You're already up to date" else echo "Updating to $latest_version..." - git fetch - git checkout "$latest_version" + $(cd "$NVM_DIR" && git fetch && git checkout "$latest_version") fi }