Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[readme] optimize calling of nvm version in zsh #2874

Merged
merged 1 commit into from
Oct 8, 2022

Conversation

robertshuford
Copy link
Contributor

The zsh hook in the readme causes cd to take unnecessarily long when working in directory tress without .nvmrc files due to always calling nvm version and nvm version default.

$ time (nvm version)
( nvm version; )  0.01s user 0.02s system 46% cpu 0.052 total
$ time (nvm version default)
( nvm version default; )  0.07s user 0.12s system 87% cpu 0.213 total

We should only call nvm version and nvm version default if we left a directory with a .nvmrc file.
nvm_find_nvmrc and nvm_find_up are fast, so by creating a similar search, but with OLDPWD, unneeded calls to nvm version and nvm version default are eliminated.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Landing this will have to wait until I've resolved CI issues unrelated to this PR, but please keep the PR/branch/fork around so I can do that :-)

@robertshuford
Copy link
Contributor Author

Looks great!

Landing this will have to wait until I've resolved CI issues unrelated to this PR, but please keep the PR/branch/fork around so I can do that :-)

Looks like I pushed a new commit seconds before you approved. Do you want me to clean up the commits on this PR or will you squash merge?

@ljharb
Copy link
Member

ljharb commented Aug 31, 2022

i'll rebase it when it's time, no worries :-)

@ljharb ljharb force-pushed the zsh-hook-update branch 2 times, most recently from 2230416 to 4893128 Compare October 8, 2022 06:32
@ljharb ljharb merged commit 4893128 into nvm-sh:master Oct 8, 2022
@robertshuford robertshuford deleted the zsh-hook-update branch September 1, 2023 03:25
carlosala added a commit to ohmyzsh/ohmyzsh that referenced this pull request Mar 4, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
fdelacruz pushed a commit to fdelacruz/ohmyzsh that referenced this pull request Mar 27, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
pull bot pushed a commit to kis87988/ohmyzsh that referenced this pull request Mar 27, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
lukaselmer pushed a commit to lukaselmer/ohmyzsh that referenced this pull request Apr 16, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
cschuyle pushed a commit to cschuyle/ohmyzsh that referenced this pull request Apr 18, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
ttelford pushed a commit to ttelford/oh-my-zsh that referenced this pull request Jun 26, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
naveen-u pushed a commit to naveen-u/ohmyzsh that referenced this pull request Jul 1, 2024
Now we only call `nvm version` in case we changed directory and we are
not anymore in a `.nvmrc` directory.
See nvm-sh/nvm#2874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants