-
Notifications
You must be signed in to change notification settings - Fork 381
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
Node must be installed or the NVM segment raises an error #212
Comments
I created PR witch removing nvm from default configuration: I prefer user explicitly adding segment to have it instead of silencing errors. Let me know what you think. |
While that avoids the problem, it would be inconsistent with the concept explained in comments in the code: "Each component will draw itself, and hide itself if no information needs to be shown". |
If NVM is not installed than how would you show the segment? And how is the user experience different from yours suggestion? |
You shouldn't show the segment if NVM is not installed. The user should not tweak anything in order to make it work without errors, out of the box, with or without NVM/node. Then if you put an obvious suggestion that says something like "for efficiency, please remove the segments that you will never use from the BULLETTRAIN_PROMPT_ORDER" that would be OK too. Something as simple as: if (( ! $+commands[node] )); then
return
fi at the beginning of the function would avoid the error and would not change the rest of the logic. |
I am not familiar with nvm but I like how Bullet Train responds to python. The python segment doesn't get triggered unless you have activated a virtual environment with
|
Marked as question as this evolves a little bit into discussion 'what is the correct behavior' |
Just writing up a pull request for this, IMO it makes more sense to do a similar thing as is done for the AWS prompt segment but to work out the node_prompt value beforehand. So, for example, if I have nvm or node then the regular logic will run and set the value of node_prompt and therefore it will be displayed in the prompt. If nvm and node are not installed then nothing gets displayed because the node_prompt is never set (unless it's set explicitly by the user for some reason.) |
I had to install NVM and Node before the error: prompt_nvm:6: command not found: node Would go away. And I don;t use either of those packages nor were they listed in the plugins section of my .zshrc file. |
I forked this theme and applied some fixes, it will show the node version without depending on NVM and fix some other issues: https://github.com/MRZ07/shinkansen.zsh-theme |
NVM is included in the default segments in BULLETTRAIN_PROMPT_ORDER, but there is no condition to avoid an error in case node is not installed. The condition is checking NVM, but it calls node either ways, which gives an error.
A condition at the start of the prompt function should return if node is not installed.
The text was updated successfully, but these errors were encountered: