Chalk: Unreadble output in one special case

Created on 30 Sep 2016  Â·  7Comments  Â·  Source: chalk/chalk

The content of this post is in reference to xo, but I believe that chalk is the source of the problem/issue. This was spotted as an xo issue (sindresorhus/xo#145). I traced that back to sindresorhus/eslint-formatter-pretty and now chalk.

Copy and pasted below

I'm not sure what's special about the output from xo, but it's the only thing that seems to be affected. I cannot read the output without copying and pasting it somewhere. Here are a few screenshots:

Normal Output

selection_2016-09-29_170518

Highlighted Output

selection_2016-09-29_170539

I've been copying the highlighted output my editor to read it. Any idea what xo is doing that's unique in this way? I've used hundreds of other cli tools including the underlying ESLint without any problems. I've used dozens of other programs that use chalk to print colorized output. I've even tried changing my local color profiles to no avail. Any help would be greatly appreciated.

For Reference

xo | tee makes the output visible although not colorized.

This is the content of the hidden output in both screenshots:

➜  ava git:(add-test-run-duration) xo

  api.js:183:2
  âš   183:2  Unexpected todo comment.                                          no-warning-comments

  lib/assert.js:15:1
  âš    15:1  This function has too many parameters (5). Maximum allowed is 4.  max-params

  lib/logger.js:94:2
  âš    94:2  Unexpected todo comment.                                          no-warning-comments

  lib/reporters/mini.js:178:4
  âš   178:4  Unexpected todo comment.                                          no-warning-comments
  âš   305:1  Unexpected todo comment.                                          no-warning-comments

  lib/test.js:42:2
  âš    42:2  Unexpected todo comment.                                          no-warning-comments

  test/cli.js:96:3
  âš    96:3  Unexpected todo comment.                                          no-warning-comments
  âš   141:3  Unexpected todo comment.                                          no-warning-comments

  test/promise.js:129:1
  âš   129:1  Unexpected todo comment.                                          no-warning-comments

  9 warnings

System Information

OS: Ubuntu 16.04 x64
Terminal: Byobu terminal
$TERM: screen-256color
$SHELL: /usr/bin/zsh
[ -t 1 ] && echo yes || echo no: yes

Most helpful comment

In case anyone else finds this post, first test your terminal emulator.

echo -e "Normal \e[8mHidden \e[28mNormal"

For anyone who's made it this far down the rabbit hole and is seeing only the first Normal in the test listed above, see this Q/A for fixes.

It took some playing for me to get this working, and in the end I aliased tmux to TERM=screen-256color-bce tmux. I already had set -g default-terminal "screen-256color" in my .tmux.conf file.

All 7 comments

This is most definitely a bug in your terminal emulator (Byobu). Please file a bug with them.

Yeah, looks like your terminal can not handle chalk.hidden.dim.gray(), probably the hidden part: https://github.com/sindresorhus/eslint-formatter-pretty/blob/d5961796a238c463fd5d2b3b1ac8d5208d34e44e/index.js#L99

Thanks for the input!

Do you know if this works in other 256 color environments?

Yes, it definitely does. XTerm should do this well.

Excellent! Thanks again.

In case anyone else finds this post, first test your terminal emulator.

echo -e "Normal \e[8mHidden \e[28mNormal"

should print
hidden style

source

In case anyone else finds this post, first test your terminal emulator.

echo -e "Normal \e[8mHidden \e[28mNormal"

For anyone who's made it this far down the rabbit hole and is seeing only the first Normal in the test listed above, see this Q/A for fixes.

It took some playing for me to get this working, and in the end I aliased tmux to TERM=screen-256color-bce tmux. I already had set -g default-terminal "screen-256color" in my .tmux.conf file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

langpavel picture langpavel  Â·  8Comments

LeoAref picture LeoAref  Â·  8Comments

basickarl picture basickarl  Â·  3Comments

Martodox picture Martodox  Â·  3Comments

erquhart picture erquhart  Â·  6Comments