From e0603314d5b2b3cbb9ca5f75a990af813cc40ae1 Mon Sep 17 00:00:00 2001 From: rmad17 Date: Fri, 26 Feb 2016 15:32:22 +0530 Subject: [PATCH 1/4] Nodeenv work --- powerlevel9k.zsh-theme | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f8e75b33..94059c14 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -556,6 +556,23 @@ prompt_nvm() { $1_prompt_segment "$0" "$2" "green" "011" "${node_version:1}" 'NODE_ICON' } +# NodeEnv Prompt +prompt_nodeenv(){ + export NODE_VIRTUAL_ENV_DISABLE_PROMPT=1 + ZSH_THEME_NODEENV_PROMPT_PREFIX="(" + ZSH_THEME_NODEENV_PROMPT_SUFFIX=")" + if [ -n "$NODE_VIRTUAL_ENV" ]; then + + if [ "`basename "$NODE_VIRTUAL_ENV"`" = "__" ] ; then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + local name="[`basename \`dirname "$NODE_VIRTUAL_ENV"\``]" + else + local name=`basename "$NODE_VIRTUAL_ENV"` + fi + echo "$ZSH_THEME_NODEENV_PROMPT_PREFIX$name$ZSH_THEME_NODEENV_PROMPT_SUFFIX" + fi +} # print a little OS icon prompt_os_icon() { From 06dd26a0bd24b52f864556931d7640a98f629472 Mon Sep 17 00:00:00 2001 From: rmad17 Date: Fri, 26 Feb 2016 16:33:19 +0530 Subject: [PATCH 2/4] Added nodeenv support --- powerlevel9k.zsh-theme | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 94059c14..441b3f21 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -556,22 +556,14 @@ prompt_nvm() { $1_prompt_segment "$0" "$2" "green" "011" "${node_version:1}" 'NODE_ICON' } + # NodeEnv Prompt -prompt_nodeenv(){ - export NODE_VIRTUAL_ENV_DISABLE_PROMPT=1 - ZSH_THEME_NODEENV_PROMPT_PREFIX="(" - ZSH_THEME_NODEENV_PROMPT_SUFFIX=")" - if [ -n "$NODE_VIRTUAL_ENV" ]; then - - if [ "`basename "$NODE_VIRTUAL_ENV"`" = "__" ] ; then - # special case for Aspen magic directories - # see http://www.zetadev.com/software/aspen/ - local name="[`basename \`dirname "$NODE_VIRTUAL_ENV"\``]" - else - local name=`basename "$NODE_VIRTUAL_ENV"` - fi - echo "$ZSH_THEME_NODEENV_PROMPT_PREFIX$name$ZSH_THEME_NODEENV_PROMPT_SUFFIX" - fi +prompt_nodeenv() { + local nodeenv_path="$NODE_VIRTUAL_ENV" + local node_version=$(node -v) + if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then + "$1_prompt_segment" "$0" "$2" "black" "green" "$(node -v)" 'NODE_ICON' "$(basename "$nodeenv_path")" + fi } # print a little OS icon @@ -827,7 +819,7 @@ prompt_vi_mode() { prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "($(basename "$virtualenv_path"))" + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" fi } From 8d0f4c9e1d4773253cf8030f0dc0defcb025a74f Mon Sep 17 00:00:00 2001 From: rmad17 Date: Fri, 26 Feb 2016 18:02:05 +0530 Subject: [PATCH 3/4] Fixed name issue --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 441b3f21..4ac6f3b0 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -560,9 +560,9 @@ prompt_nvm() { # NodeEnv Prompt prompt_nodeenv() { local nodeenv_path="$NODE_VIRTUAL_ENV" - local node_version=$(node -v) if [[ -n "$nodeenv_path" && "$NODE_VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "black" "green" "$(node -v)" 'NODE_ICON' "$(basename "$nodeenv_path")" + local info="$(node -v)[$(basename "$nodeenv_path")]" + "$1_prompt_segment" "$0" "$2" "black" "green" "$info" 'NODE_ICON' fi } @@ -819,7 +819,7 @@ prompt_vi_mode() { prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n "$virtualenv_path" && "$VIRTUAL_ENV_DISABLE_PROMPT" != true ]]; then - "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$(basename "$virtualenv_path")" + "$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "($(basename "$virtualenv_path"))" fi } From 163ac2697c45a5438be5b89fb9af53f208c56a75 Mon Sep 17 00:00:00 2001 From: rmad17 Date: Fri, 26 Feb 2016 19:43:44 +0530 Subject: [PATCH 4/4] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c04f5620..acce6ced 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ The segments that are currently available are: * [ip](#ip) - Shows the current IP address. * **load** - Your machines 5 minute load average. * **node_version** - Show the version number of the installed Node.js. +* **nodeenv** - [nodeenv](https://github.com/ekalinin/nodeenv) prompt for displaying node version and environment name. * **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.