From 7e6339ec2770bacc71ba83139330aec574f752f6 Mon Sep 17 00:00:00 2001 From: Alex LaFroscia Date: Mon, 12 Oct 2015 00:28:33 -0400 Subject: [PATCH 1/2] Add NVM prompt segment Prints out the Node version that is currently active if it is different than the default version specified by NVM --- powerlevel9k.zsh-theme | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c2ee2625..af146d4e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -752,6 +752,17 @@ prompt_php_version() { fi } +# Node version from NVM +# Only prints the segment if different than the default value +prompt_nvm() { + local node_version=$(nvm current) + local nvm_default=$(cat $NVM_DIR/alias/default) + [[ -z "${node_version}" ]] && return + [[ "$node_version" =~ "$nvm_default" ]] && return + NODE_ICON=$'\u2B22' # ⬢ + $1_prompt_segment "$0" "green" "011" "${node_version:1} $NODE_ICON" +} + # rbenv information prompt_rbenv() { if [[ -n "$RBENV_VERSION" ]]; then From d5ffa502e26b574577f523e22476f23ec4567083 Mon Sep 17 00:00:00 2001 From: Alex LaFroscia Date: Tue, 13 Oct 2015 19:17:08 -0400 Subject: [PATCH 2/2] Add note about NVM to the readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4baf0629..281f5b5a 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ The segments that are currently available are: * [ip](#ip) - Shows the current IP address. * **load** - Your machines 5 minute load average and free RAM. * **node_version** - Show the version number of the installed Node.js. +* **nvm** - Show the version of Node that is currently active, if it differs from the version used by NVM * **os_icon** - Display a nice little icon, depending on your operating system. * **php_version** - Show the current PHP version. * [rbenv](#rbenv) - Ruby environment information (if one is active).