You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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.
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
withls --color
orgit
withgit --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 (usinginotify
or faking a TTY).The text was updated successfully, but these errors were encountered: