mirror of
https://github.com/lukechilds/zsh-nvm.git
synced 2025-02-06 09:55:31 +08:00
Move all cd commands into sub commands
This is to stop the user's CWD being changed
This commit is contained in:
parent
eb40361f00
commit
03d7a4bce4
@ -22,22 +22,19 @@ _zsh_nvm_latest_release_tag() {
|
|||||||
|
|
||||||
_zsh_nvm_install() {
|
_zsh_nvm_install() {
|
||||||
git clone https://github.com/creationix/nvm.git "$NVM_DIR"
|
git clone https://github.com/creationix/nvm.git "$NVM_DIR"
|
||||||
cd "$NVM_DIR"
|
$(cd "$NVM_DIR" && git checkout --quiet "$(_zsh_nvm_latest_release_tag)")
|
||||||
git checkout --quiet "$(_zsh_nvm_latest_release_tag)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_update() {
|
nvm_update() {
|
||||||
cd "$NVM_DIR"
|
|
||||||
echo "Checking latest version of nvm..."
|
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)
|
local latest_version=$(_zsh_nvm_latest_release_tag)
|
||||||
echo "Installed version is $installed_version"
|
echo "Installed version is $installed_version"
|
||||||
if [[ "$installed_version" = "$latest_version" ]]; then
|
if [[ "$installed_version" = "$latest_version" ]]; then
|
||||||
echo "You're already up to date"
|
echo "You're already up to date"
|
||||||
else
|
else
|
||||||
echo "Updating to $latest_version..."
|
echo "Updating to $latest_version..."
|
||||||
git fetch
|
$(cd "$NVM_DIR" && git fetch && git checkout "$latest_version")
|
||||||
git checkout "$latest_version"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user