Nvm: Terminal colors destroy output of nvm commands

Created on 21 Dec 2017  Â·  5Comments  Â·  Source: nvm-sh/nvm

As per @ljharb when using colored terminal, this can mess with nvm's output.

For example. I use zsh, oh-my-zsh & spaceship-zsh-theme (i.e. have a colorful terminal ;) )

When writing an Ansible playbook, I was trying to use the following to ensure that current node version was set;

nvm ls | grep -e 'default -> v8.9.3'

This was returning an Exit code 1, because of my colored terminal. The addition of TERM=dumb nvm ls fixed this.

~/src/ansible on dev
➜ nvm ls
         v8.9.3
default -> v8.9.3
node -> stable (-> v8.9.3) (default)
stable -> 8.9 (-> v8.9.3) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.3)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.12.2 (-> N/A)
lts/carbon -> v8.9.3
~/src/ansible on dev
➜ TERM=dumb nvm ls
         v8.9.3 *
default -> v8.9.3 *
node -> stable (-> v8.9.3 *) (default)
stable -> 8.9 (-> v8.9.3 *) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.3 *)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.12.2 (-> N/A)
lts/carbon -> v8.9.3 *

We need to fix the --help output, and probably add some info to the Readme.md about this.

informational pull request wanted

All 5 comments

Also, nvm ls --no-colors will work; which is documented in nvm --help: Any options that produce colorized output should respect the `--no-colors` option.

I guess this can be closed?

Still needs some documentation to be updated :-)

I created PR #2004. Let me know what you think.

I guess this can be closed now? :-)

Was this page helpful?
0 / 5 - 0 ratings