0

I'm not too versed with the terminal. I'm using zsh with prezto and I wanted to show the node version in the prompt. At the prezto repo they provide these instructions: https://github.com/sorin-ionescu/prezto/tree/master/modules/node

And I can follow up to the last part:

Then add $node_info[version] to either $PROMPT or $RPROMPT and call node-info in prompt_name_preexec hook function.

I added $node_info[version] to the $PROMPT in my theme file, but what does it mean to call node-info in the prompt_name_preexec hook? is that a function inside my theme file? I honestly have no clue what is talking about.

Thanks!

oquiroz
  • 85
  • 5
  • 14

2 Answers2

0

There are multiple files associated with Zsh prompt themes, Like prompt_name_setup, prompt_name_preview, prompt_name_help, prompt_name_preexec. Only prompt_name_setup is required and others are optional, These files are stored somewhere in $fpath. Replace that name with your current prompt theme (prompt -c).

To show your node version in prezto, Add the following to your prompt_name_setup.

zstyle ':prezto:module:node:info:version' format 'version:%v'

Create if you don't have a file named prompt_name_preexec in your $fpath or add this to it as PROMPT or RPROMPT variable.

$node_info[version]

After reloading your terminal, Verify its added by echo $PROMPT or echo $RPROMPT.


If you don't want any of the hassle and want to show node version in your prompt, Use a prompt theme like spaceship-prompt (Disclaimer: I'm one of the maintainer)

salmanulfarzy
  • 1,484
  • 14
  • 18
0

One can add PS1+="$(node --version)" to the $PS1 variable to display current node version

theredcap
  • 632
  • 6
  • 13