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

node/nvm version behavior (only show when a package.json file is present and use the nvm version) #373

Closed
leeallen337 opened this issue Dec 12, 2019 · 3 comments

Comments

@leeallen337
Copy link

I'm unsure if this is possible since there are multiple node settings. I've attached a gif.

Kapture 2019-12-11 at 21 35 31

In that node-starter directory there is a package.json file and it doesn't show the node version initially which I would expect since in the config this setting is set:

typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true

However, only after I use nvm use (since there is an .nvmrc) does it show the node version, and when I do an nvm use defaultit goes back to not showing it again. Also if I do annvm useand then navigate out of that directory to a directory that doesn't have apackage.json` file it still shows the node version.

What behavior I would like to happen:

It always, but only, shows the node version when the directory has a package.json file. If the directory does not have a package.json file then don't show any node information.

Thanks for this awesome theme!

@romkatv
Copy link
Owner

romkatv commented Dec 12, 2019

At the top of ~/.p10k.zsh you can find the following definition:

# The list of segments shown on the right.
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
  ...
  nodenv          # node.js version from nodenv (https://github.com/nodenv/nodenv)
  nvm             # node.js version from nvm (https://github.com/nvm-sh/nvm)
  nodeenv         # node.js environment (https://github.com/ekalinin/nodeenv)
  # node_version  # node.js version
  ...
)

There are several prompt segments that refer to node.js version. The last segment -- node_version -- is essentially a wrapper around node --version. Note that it's commented out (disabled). The other prompt segments fetch node version from various node version managers.

Below this, there is one section for each prompt segment that defines parameters specifically for that segment. For example, here's what the config has for node_version.

####################[ node_version: node.js version ]#####################
# Show node version only when in a directory tree containing package.json.
typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true
...

POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true works just like you would expect. However, it has no effect if node_version isn't enabled.

What behavior I would like to happen:

It always, but only, shows the node version when the directory has a package.json file. If the directory does not have a package.json file then don't show any node information.

You can achieve the desired behavior by uncommenting node_version and commenting out the other three node segments.

Thanks for this awesome theme!

Thanks 🤗

@leeallen337
Copy link
Author

This worked exactly like you said! Thanks 🙏

@romkatv romkatv closed this as completed Dec 13, 2019
@romkatv
Copy link
Owner

romkatv commented Dec 13, 2019

Thanks for the confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants