edkolev / promptline.vim

Generate a fast shell prompt with powerline symbols and airline colors
MIT License
625 stars 54 forks source link

Node version slice when using nvm #47

Open jhacksworth opened 8 years ago

jhacksworth commented 8 years ago

If you're using nvm (Node Version Manager), this will show the active Node.js/io.js version:

'$(nvm_ls_current 2>/dev/null | grep -v none)'

Here's my preset, for example, where I put the node version in the a section:

let g:promptline_preset = {
        \'a'    : [ promptline#slices#python_virtualenv(), '$(nvm_ls_current 2>/dev/null | grep -v none)', '$USER', promptline#slices#host({ 'only_if_ssh': 1 })],
        \'b'    : [ promptline#slices#vcs_branch(), promptline#slices#git_status() ],
        \'c'    : [ '\w' ],
        \'warn' : [ promptline#slices#last_exit_code() ]}

The a section will show virtualenv, node version, user name and, if logged in through ssh, host name.

Is there a proper place to save these type of examples, maybe a wiki page?

edkolev commented 8 years ago

Sure, you can add a wiki page with details about this.

BTW you can use something like this to avoid calling grep:

$( nvm_version="$(nvm_ls_current)"; echo ${nvm_version#none} )

I haven't tested it much though