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_version_prompt should work without NVM #1946

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions themes/base.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,27 @@ function hg_prompt_vars() {
fi
}

function node_command_version_prompt() {
local node_version
if _command_exists node; then
node_version="$(node --version 2> /dev/null)"
if [[ -n ${node_version} ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

This check would give a false positive when using version management shims that are common with tools like asdf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you clarify? What do you mean by a false positive?

if node --version returns a non-empty output, doesn't that mean that this is the current node version? If so, why not show it in the prompt?

echo -e "${NVM_THEME_PROMPT_PREFIX}${node_version}${NVM_THEME_PROMPT_SUFFIX}"
fi
fi
}

function node_version_prompt() {
local node_version
node_version="$(nvm_version_prompt)"
if [[ -z "${node_version}" ]]; then
node_version="$(node_command_version_prompt)"
fi
if [[ -n "${node_version}" ]]; then
echo -e "${node_version}"
fi
}

function nvm_version_prompt() {
local node
if _is_function nvm; then
Expand All @@ -399,10 +420,6 @@ function nvm_version_prompt() {
fi
}

function node_version_prompt() {
nvm_version_prompt
}

function rvm_version_prompt() {
if _command_exists rvm; then
rvm="$(rvm-prompt)" || return
Expand Down
4 changes: 2 additions & 2 deletions themes/powerline-multiline/powerline-multiline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=28}

RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=161}
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=1}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "}

TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
Expand Down