From d1a22a63bd38c0392393044354297e5ca02bc0cf Mon Sep 17 00:00:00 2001 From: "JC (Jonathan Chen)" Date: Sun, 9 Apr 2023 09:21:56 -0400 Subject: [PATCH] [readme] `cdnvm` function: fix shellcheck errors Resolves #3081 --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1382d2b..e6b6a82 100644 --- a/README.md +++ b/README.md @@ -599,8 +599,9 @@ cdnvm() { fi fi } + alias cd='cdnvm' -cd "$PWD" +cdnvm "$PWD" || exit ``` This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version. @@ -615,11 +616,14 @@ Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you e ```zsh # place this after nvm initialization! autoload -U add-zsh-hook + load-nvmrc() { - local nvmrc_path="$(nvm_find_nvmrc)" + local nvmrc_path + nvmrc_path="$(nvm_find_nvmrc)" if [ -n "$nvmrc_path" ]; then - local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") + local nvmrc_node_version + nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") if [ "$nvmrc_node_version" = "N/A" ]; then nvm install @@ -631,6 +635,7 @@ load-nvmrc() { nvm use default fi } + add-zsh-hook chpwd load-nvmrc load-nvmrc ```