diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 8d90f043..d193191e 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -62,6 +62,9 @@ SCM_SVN_CHAR='⑆' SCM_NONE='NONE' SCM_NONE_CHAR='○' +NVM_THEME_PROMPT_PREFIX=' |' +NVM_THEME_PROMPT_SUFFIX='|' + RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_SUFFIX='|' @@ -306,6 +309,19 @@ function hg_prompt_vars { fi } +function nvm_version_prompt { + local node + if declare -f -F nvm &> /dev/null; then + node=$(nvm current 2> /dev/null) + [[ "${node}" == "system" ]] && return + echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}" + fi +} + +function node_version_prompt { + echo -e "$(nvm_version_prompt)" +} + function rvm_version_prompt { if which rvm &> /dev/null; then rvm=$(rvm-prompt) || return diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index ee6095dd..965c593a 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -56,6 +56,7 @@ The contents of both prompt sides can be "reordered", all the "segments" (every * `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) * `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index ad64fb18..dcd1a51b 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -29,6 +29,11 @@ SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} +NVM_THEME_PROMPT_PREFIX="" +NVM_THEME_PROMPT_SUFFIX="" +NODE_THEME_PROMPT_COLOR=22 +NODE_CHAR=${POWERLINE_NODE_CHAR:="❲n❳ "} + RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" @@ -57,7 +62,7 @@ IN_VIM_THEME_PROMPT_TEXT="vim" HOST_THEME_PROMPT_COLOR=0 -POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} +POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index da5e254b..1f16c296 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -54,6 +54,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) * `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 81025c84..6b8859bd 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -26,6 +26,11 @@ SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 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=22 + RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" @@ -57,6 +62,6 @@ IN_VIM_THEME_PROMPT_TEXT="vim" HOST_THEME_PROMPT_COLOR=254 -POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} +POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index 701b9fa1..6ea21a18 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -52,6 +52,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) * `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index f9538c2a..c3ce1817 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -21,6 +21,11 @@ SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 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=22 + RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" @@ -52,6 +57,6 @@ IN_VIM_THEME_PROMPT_TEXT="vim" HOST_THEME_PROMPT_COLOR=0 -POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} +POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} -safe_append_prompt_command __powerline_prompt_command \ No newline at end of file +safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline/README.md b/themes/powerline/README.md index 974bcbeb..acb51d9f 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -56,6 +56,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) * `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 9e668a6c..5fe6614d 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -40,6 +40,13 @@ function __powerline_user_info_prompt { [[ -n "${user_info}" ]] && echo "${user_info}|${color}" } +function __powerline_node_prompt { + local node_version="" + + node_version="$(node_version_prompt)" + [[ -n "${node_version}" ]] && echo "${NODE_CHAR}${node_version}|${NODE_THEME_PROMPT_COLOR}" +} + function __powerline_ruby_prompt { local ruby_version="" diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 377e6f8e..bff8a6ca 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -24,6 +24,11 @@ SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 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=22 + RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" @@ -55,7 +60,7 @@ IN_VIM_THEME_PROMPT_TEXT="vim" HOST_THEME_PROMPT_COLOR=0 -POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} +POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} HISTORY_AUTOSAVE=${HISTORY_AUTOSAVE:-0}