Skip to content
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

ansi colors not displayed within linux watch command #840

Closed
gberche-orange opened this issue May 12, 2016 · 9 comments
Closed

ansi colors not displayed within linux watch command #840

gberche-orange opened this issue May 12, 2016 · 9 comments
Labels
closed due to inactivity closed due to inactivity - reopen if this is still an issue unscheduled

Comments

@gberche-orange
Copy link

gberche-orange commented May 12, 2016

Starting with 6.17.1 the watch -c cf a is not displaying colors anymore. Suspecting that the colors improvements brought in 6.17.1 are misleadingly detecting the "watch-exposed terminal" as not supporting colors, and regressed. The same command is properly displaying colors in 6.17.0 version

nb: some related diagnostic in some other cf-unrelated cli commands

Command

watch -c cf a

CLI Version

Reproduces in

$ cf-6.17.1 -v
cf version 6.17.1+2ca614d-2016-05-02

$ cf -v
cf version 6.18.0+b22884b-2016-05-10

Platform Details

Ubuntu:

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.10
DISTRIB_CODENAME=wily
DISTRIB_DESCRIPTION="Ubuntu 15.10"

Shell

Bash

$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/119446319

The labels on this github issue will be updated when the story is started.

@XenoPhex
Copy link
Contributor

Recently the CF CLI switched color libraries in order to support windows. This color library is significantly more robust for things like supporting the same colors, highlighting words, etc. However, it also detects whether you are in a TTY session. If you are not in a TTY session, this library will automatically not output colors. Whenever you run a CF command inside another command or pipe it through a series of commands, the command knows it's not in a TTY and will not output colors.

There is no way to cleanly force colors to be on for these situations.

@gberche-orange
Copy link
Author

thanks @XenoPhex for looking int this issue. Any chance to contribute to this library to add a configureable mode to bypass the tty detection and force color output ?

In terms of UX for cf cli, this could end-up in new accepted values for the CF_COLORS env var
/CC @dkoper

CF_COLOR=true|false|always                     Controls output colorization

This would be similar to common pattern used in ls command:

$ man ls
[...]
       --color[=WHEN]
              colorize the output; WHEN can be 'never', 'auto', or 'always' (the default); more info below
[...]
     Using  color  to  distinguish  file types is disabled both by default and with --color=never.  With --color=auto, ls emits color codes only when standard
       output is connected to a terminal.  The LS_COLORS environment variable can change the settings.  Use the dircolors command to set it.

@krishicks
Copy link
Contributor

krishicks commented Jul 27, 2016

This also affects the cf-resource in Concourse, which is a big sadface.

cc @xoebus

@dkoper
Copy link

dkoper commented Aug 30, 2016

We'd like to address this issue in the next release.

ls and grep default to always but commonly aliased to --color=auto hence the need for --color in watch ls --color.

Rather than introducing a new environment variable, would a global --color option satisfy?
watch -c cf a --color
with --color [never|always|auto], defaulting to always if no value specified.
cf config --color would accept the same values, aliasing never to false and auto to true for compatibility, which applies when running any cf command without the --color flag.
->@gberche-orange @krishicks

@gberche-orange
Copy link
Author

@dkoper thanks for priorizing this issue.

+1 for your proposal to add a --color common flag to all commands e.g. in cf a --color always as well as a cf config --color applying when no color flag is provided in a given command.

@dkoper
Copy link

dkoper commented Aug 31, 2016

Sorry, I'd like to take that back, I had missed we already expose CF_COLOR!

Instead, I'd like to address this by fixing the behaviour of this environment variable as it was before: true means force colors. So e.g. watch -c CF_COLOR=true cf a should work again.

At the same time, I'd like to extend cf config --color with an auto value, which would be the default.

Would that work for you?

@XenoPhex
Copy link
Contributor

Hi @gberche-orange we are closing this issue due to inactivity. Also watch does not function for this type of behaviour (note the control characters):

Every 2.0s: CF_COLOR=true cf app test-app-1                                                             unicorn: Thu Apr 12 14:18:29 2018

Showing health and status for app ^[36;1mtest-app-1^[0m in org ^[36;1mInfinity Nights^[0m / space ^[36;1mwork-related^[0m as ^[36;1magait
onde@pivotal.io^[0m...

name:              test-app-1
requested state:   stopped
instances:         0/1
usage:             1G x 1 instances
routes:
last uploaded:     Tue 03 Apr 09:57:33 PDT 2018
stack:             cflinuxfs2
buildpack:

There are no running instances of this app.

@XenoPhex XenoPhex added the closed due to inactivity closed due to inactivity - reopen if this is still an issue label Apr 12, 2018
@gberche-orange
Copy link
Author

gberche-orange commented Apr 26, 2018

@XenoPhex sorry for the late response to dkoper in #840 (comment). This suggestion seem fine to me.

I'm not sure what you mean by " watch does not function for this type of behaviour (note the control characters)", which indeed seems the problem I reported into this issue.

I'm not reproducing the bug in the cf app command, which properly colorizes the org and space name, but in the cf apps command

$ cf -v
cf version 6.35.2+88a03e995.2018-03-15
$ watch -c CF_COLOR=true cf app spring-travel

image

$ watch -c CF_COLOR=true cf apps
image

Note the watch -c argument for having the command interpret control characters:

$ watch --help
[...]
Options:
  -c, --color            interpret ANSI color and style sequences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed due to inactivity closed due to inactivity - reopen if this is still an issue unscheduled
Projects
None yet
Development

No branches or pull requests

5 participants