Skip to content

Commit

Permalink
Merge pull request #2142 from matthewadams/node
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Nov 7, 2024
2 parents 7fd874b + 5913d22 commit 60eb7bf
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/themes-list/powerline-base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv``
and ``conda`` supported)
* ``ruby`` - Current ruby version if using ``rvm``
* ``node`` - Current node version (only ``nvm`` is supported)
* ``node`` - Current node version (``nvm`` is the default strategy; set ``NODE_VERSION_STRATEGY`` to ``node`` to use ``node --version``)
* ``scm`` - Version control information, ``git``
* ``terraform`` - Current terraform workspace
* ``user_info`` - Current user
Expand Down
21 changes: 20 additions & 1 deletion themes/base.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ SCM_NONE_CHAR='○'
NVM_THEME_PROMPT_PREFIX=' |'
NVM_THEME_PROMPT_SUFFIX='|'

NODE_THEME_PROMPT_PREFIX=' |'
NODE_THEME_PROMPT_SUFFIX='|'

RVM_THEME_PROMPT_PREFIX=' |'
RVM_THEME_PROMPT_SUFFIX='|'

Expand Down Expand Up @@ -399,8 +402,24 @@ function nvm_version_prompt() {
fi
}

function node_native_version_prompt() {
local node
if _command_exists node; then
node=$(node --version 2> /dev/null)
echo -ne "${NODE_THEME_PROMPT_PREFIX-}${node}${NODE_THEME_PROMPT_SUFFIX-}"
fi
}

function node_version_prompt() {
nvm_version_prompt
NODE_VERSION_STRATEGY="${NODE_VERSION_STRATEGY:-nvm}"

_log_debug "node: using version strategy '$NODE_VERSION_STRATEGY'"

if [ "$NODE_VERSION_STRATEGY" == "nvm" ]; then
nvm_version_prompt
elif [ "$NODE_VERSION_STRATEGY" == "node" ]; then
node_native_version_prompt
fi
}

function rvm_version_prompt() {
Expand Down
2 changes: 2 additions & 0 deletions themes/powerline-multiline/powerline-multiline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}

NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_THEME_PROMPT_PREFIX=""
NODE_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}

Expand Down
2 changes: 2 additions & 0 deletions themes/powerline-naked/powerline-naked.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}

NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_THEME_PROMPT_PREFIX=""
NODE_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}

Expand Down
2 changes: 2 additions & 0 deletions themes/powerline-plain/powerline-plain.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}

NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_THEME_PROMPT_PREFIX=""
NODE_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}

Expand Down
2 changes: 2 additions & 0 deletions themes/powerline/powerline.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}

NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_THEME_PROMPT_PREFIX=""
NODE_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}

Expand Down

0 comments on commit 60eb7bf

Please sign in to comment.