-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Pre / post activate hooks #1932
Comments
For now, a work-around is:
However this doesn't cover the case of detecting environment changes, which is an important missing. |
What’s the use case? Do you want hooks for any invocation of nvm, or only a use command? |
Updating my prompt is my use case, so changing environments would be sufficient for me. My workaround doesn't detect environment changes but naively runs the prompt update every time |
I'm confused; i have my prompt set up to call |
The performance figures I get are as follows:
Delaying a prompt by almost 0.2 seconds every time doesn't work, especially if its cumulative with The best way I've seen it done in other environment managers is where they set an environment variable denoting the version currently activated. I work around
Using a variable makes the prompt delay possible far more palatable: 0.009 vs 0.188 on an idle system. If |
I was looking for such a feature, but my use case was to be able to specify commands to be run after each |
@waldyrious given that having pretty much anything installed globally is an antipattern, i'd love to hear more about your use case - what global packages do you have that need frequent updating? |
@ljharb in my case I use |
@waldyrious you can do that with https://github.com/creationix/nvm#default-global-packages-from-file-while-installing already. |
Yes, but IIUC that only works when |
Sure, but |
Sure, that can work :) |
@waldyrious ok so, with |
@ljharb semantically, I think it would make more sense to run That said, I wouldn't object if you prefer ruling out implementing the same behavior for |
Which, the default packages behavior? If so it'd have to be with a flag, like |
I was thinking more of But I'm sure there are stronger justifications for the separation. Again, resorting to running |
|
OK, it seems like this is addressed then :-) if there's new use cases, I'll be happy to reopen :-) |
I'm revisiting this issue as I'm developing JavaScript again. Approx 0.2 seconds per prompt is quite slow. If I press enter a bunch of times, I have 'gaps' where the enter is echoed to the screen faster than the prompt can be redrawn. And it's not just Perhaps as a work-around, |
Sadly performance improvements to My prompt is slow because |
@HaleTom you're the first person to ever report that; could you please file a new issue about it and fill out the full template? I’d love to resolve it. |
Operating system and version:
nvm debug
output:nvm ls
output:nvm
? (e.g. install script in readme, Homebrew):curl
Feature request: Pre / post activate hooks
Can the pre- and post- activation scripts be called with the names of the previous and next environment?:
Eg: when sourcing nvm from
.bashrc
, the following could be called$NVM_DIR/pre-hook "" "system"
...
system
is added to path, etc...$NVM_DIR/post-hook "" system"
(note the "previous" version is "" as there was none)
If then switching from
system
tov6.11.4
vianvm use v6.11.4
:$NVM_DIR/pre-hook "system" "v6.11.4"
$NVM_DIR/post-hook "system" "v6.11.4"
Note: both
conda
andvirtualenvwrapper
support hook scripts.The text was updated successfully, but these errors were encountered: