Skip to content

Node js colors don't work in Git bash, but works in Powershell and CMD #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
IdkGoodName opened this issue Jan 1, 2019 · 2 comments
Closed
1 task done

Comments

@IdkGoodName
Copy link

IdkGoodName commented Jan 1, 2019

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

Git bash version:

$ git --version --build-options

git version 2.20.1.windows.1
cpu: x86_64
built from commit: 7c9fbc07db0e2939b36095df45864b8cda19b64f
sizeof-long: 4
sizeof-size_t: 8

Windows options: Windows 10 64-bit

$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17134.472]

Options:

Editor Option: VisualStudioCode
Custom Editor Path: 
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled

Python rgb colors work on Git bash, but not in node js. I figured out that CMD and PowerShell shows node js rgb colors.

Details

  • Which terminal/shell are you running Git from?

Git Bash

  • What commands did you run to trigger this issue?
$ node index.js
$ py index.py

index.js

const rainbow = () => {
    for(let i = 0; i < 15; i++) {
        process.stdout.write('\033[48;2;255;' + (i * 16) + ';0m.\x1b[0m')
    }
    for(let i = 0; i < 15; i++) {
        process.stdout.write('\033[48;2;' + (255 - (i * 16)) + ';255;0m.\x1b[0m')
    }
    for(let i = 0; i < 15; i++) {
        process.stdout.write('\033[48;2;0;255;' + (i * 16) + 'm.\x1b[0m')
    }
    for(let i = 0; i < 15; i++) {
        process.stdout.write('\033[48;2;0;' + (255 - (i * 16)) + ';255m.\x1b[0m')
    }
}
rainbow()

index.py

import sys
def rainbow():
    for i in range(15):
        sys.stdout.write('\x1b[48;2;255;' + str(i * 16) + ';0m.\x1b[0m')
    for i in range(15):
        sys.stdout.write('\x1b[48;2;' + str(255 - (i * 16)) + ';255;0m.\x1b[0m')
    for i in range(15):
        sys.stdout.write('\x1b[48;2;0;255;' + str(i * 16) + 'm.\x1b[0m')
    for i in range(15):
        sys.stdout.write('\x1b[48;2;0;' + str(255 - (i * 16)) + ';255m.\x1b[0m')
    sys.stdout.write('\n')
rainbow()
  • What did you expect to occur after running these commands?

Same results when running both commands.

  • What actually happened instead?

Node js command shows 5 colors, meanwhile, Python command shows rainbow.

@dscho
Copy link
Member

dscho commented Jan 2, 2019

node index.js

Can you try to run it through node.exe, i.e. node.exe index.js?

@dscho
Copy link
Member

dscho commented Feb 27, 2019

Apparently not...

@dscho dscho closed this as completed Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants