From 0e3848093aa1dbb70a99bce5b623a37669e08756 Mon Sep 17 00:00:00 2001 From: Zeh Rizzatti Date: Thu, 13 Dec 2012 12:26:01 -0300 Subject: [PATCH] Add node-info function Minimal configuration required prior to calling node-info is: ztyle -s ':prezto:module:node:info:version' format '%v' $node_info[version] will contain the current version of node.js on the path, if nvm is loaded. This information can be used in prompts like $ruby_info. --- modules/node/functions/node-info | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 modules/node/functions/node-info diff --git a/modules/node/functions/node-info b/modules/node/functions/node-info new file mode 100644 index 00000000..f2eca0b6 --- /dev/null +++ b/modules/node/functions/node-info @@ -0,0 +1,26 @@ +# vim: ft=zsh +# +# Exposes information about the node.js environment via the $node_info +# associative array. +# +# Authors: +# Zeh Rizzatti +# + +local version +local version_format +local version_formatted + +unset node_info +typeset -gA node_info + +if (( $+functions[nvm_version] )); then + version="${$(nvm_version)#v}" +fi + +if [[ -n "$version" ]]; then + zstyle -s ':prezto:module:node:info:version' format 'version_format' + zformat -f version_formatted "$version_format" "v:$version" + node_info[version]="$version_formatted" +fi +