From 5f4766d9f6c9d69cef96fc7ce3ba20d9785922f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20Fr=C3=B6hlich?= Date: Mon, 4 Dec 2017 07:35:07 +0100 Subject: [PATCH] Update README.md Passes all given arguments to cd and respects the outcome of a failed cd. --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10a2cc9..665a37a 100644 --- a/README.md +++ b/README.md @@ -386,13 +386,8 @@ Put this into your `$HOME/.bashrc` to call `nvm use` automatically whenever you ```bash # place this after nvm initialization! cd() { - if [ -z "$1" ] - then - builtin cd - else - builtin cd $1 - fi - [ -f ".nvmrc" ] && [ -s ".nvmrc" ] && nvm use + builtin cd "$@" + [ $? -eq 0 ] && [ -f ".nvmrc" ] && [ -s ".nvmrc" ] && nvm use } ```