Open unikitty37 opened 3 years ago
nvm is not supported when installed from homebrew (altho this issue seems unrelated); please brew uninstall it and reinstall it from the only supported install method (the install script in the readme).
I'm not sure why nodenv init
would matter, since this is nvm, not nodenv? Similarly, I'm not sure why there's nodenv
in your path anywhere if you're using nvm. Can you elaborate?
I can reproduce this issue, and I completely agree that when it's in a pipe, it shouldn't output colors. I don't think "TTY-ness" should dictate that, since it's not about interactivity (but your suggestion would certainly work, albeit with a lot of added complexity in nvm).
Using some form of this technique should work here - when I naively use it in nvm_has_colors
, the "ls" part of the nvm ls
output works properly, but in an actual terminal it causes the "alias" part of the nvm ls
output to drop its colorization, so some finesse might be needed. tagging in @gitburd and @naomiquinones for help.
Thanks — I'm not 100% sure why nodenv was installed; it must have been left over from some time ago. For some reason zsh initialisation was working with it at the end of the file right up until I installed nvm, but removing nodenv entirely fixed it, and seems to be the more sensible option :)
I've cover help
, ls
, ls-remote
and alias
. Let me know if some issue with this PR.
Unfortunately the PR's fork was deleted, so this issue still needs a PR.
I've been exploring a fix to this. It's of course a breaking change, which is fine. It's also a highly disruptive one, however.
Currently you can do nvm ls --no-colors | whatever
or TERM=dumb nvm ls | whatever
and skip the colors.
With this change, you'd need do do nvm ls --colors | whatever
.
I think this change would be much less disruptive if it was confined to pipes - but "$(nvm ls)"
seems to be indistinguishable from nvm ls | echo
from nvm ls
's POV.
Operating system and version: macOS 10.14.6 (18G8022)
nvm debug
output:nvm ls
output:How did you install
nvm
?Homebrew
What steps did you perform?
nvm ls | pbcopy
What happened?
All the ANSI codes were copied to the clipboard, as you can see from the section above.
What did you expect to happen?
nvm ls
should omit ANSI colour codes and outputs plain text when being piped to another command. This is in line with how other colour-using commands work, so would be generally expected behaviour. Having to add--no-colors
each time is a workaround, but it does not mirror the behaviour of other commands, which do the right thing automatically.Perhaps the default behaviour could be to use colours when outputting to a TTY, and no colours when not outputting to a TTY, and adding a new
--colors
flag which could be used to force the issue when colours are required in a pipe?Is there anything in any of your profile files that modifies the
PATH
?Yes; they all execute after
eval "$(nodenv init -)"
, which is at the top of the file.