Skip to content

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

Closed
@IdkGoodName

Description

@IdkGoodName
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions