Skip to content
New issue

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

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

Already on GitHub? # to your account

Add option to force colored output when colorls is not outputting directly to the console #236

Closed
1 of 5 tasks
eliezercabrera opened this issue Nov 5, 2018 · 1 comment

Comments

@eliezercabrera
Copy link

Description

I want to use colorls to display the file tree of a particular directory, and update when files are created, removed, or renamed.

A nice utility to do this is watch, so I tried a command like:

watch -n 0.5 -t colorls --tree --light

Which does work, it basically calls the colorls command every 0.5 seconds. But the output is not colored, all of it is in default color (black for my light theme).

Reading the man page for watch, I noticed that it has an option -c that interprets color escape sequences. But, when running:

watch -n 0.5 -t -c colorls --tree --light

the same happened. It just interprets escape sequences as colors, the program being run (i.e. colorls) needs to send the escape sequences in the first place.

Googling around, I found out that this kind of behaviour is not uncommon. Programs can detect when they are running in a script or when otherwise their output is not being displayed directly into a TTY. When they detect that, they can choose not to use color escape sequences.

That is why some utilities, like ls with ls --color or git with git --color=always have flags to force colored output.

I'd like colorls to have a similar option.

P.s. A script such as while sleep 0.5; do colorls --light --tree; end would show color, but the output blinks a lot. watch gets around this issue by buffering the output, which is precisely why programs detect they are not outputting directly to the console. I'm currently trying to hack a solution (using inotify or faking a TTY).

  • Type of issue :
    • Installation
    • Font-related
    • Feature request
    • Bug in existing feature
    • Developer mode : Code quality / Tests / Documentation
@avdv
Copy link
Collaborator

avdv commented Nov 5, 2018

This is already implemented in #227, but it is not yet released. So, you would have to checkout the master branch and build colorls from source until the new version is ready.

@avdv avdv closed this as completed Nov 5, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants