You are not logged in.
Pages: 1
Is it possible to have the more, less, tail, or head commands retain the color in the console? For instance, "pacman-color -Ss kde4 | more" will strip all the colors. ...or is there an alternative command that I may not know about that retains the colors?
Thanks,
Jason
Offline
As you noticed apps can see if they output to tty or a pipe. I don't know about pacman-color (check its man page), but for ls and grep and such there is --color=always. And then less has -R to interpret it correctly (not sure if it's necessary).
Offline
I'm not sure if it's exactly what you need, but it might be helpfull, check this post:
http://bbs.archlinux.org/viewtopic.php? … 69#p518569
When everything's coming your way, you're in the wrong lane I say.
FAQ / Beginners Guide / The Arch Way
Offline
My bash's colors:
-> $PS1 (the prompt)
-> ls
-> grep
-> vi
-> manpages
-> colordiff
-> pacman-color
-> colorgcc
these lines below work for the manpages, but they do not work on less.
export LESS_TERMCAP_md=$'\e[01;34m';
export LESS_TERMCAP_mb=$'\e[00;34m';
export LESS_TERMCAP_me=$'\e[00;00m';
export LESS_TERMCAP_se=$'\e[00;00m';
export LESS_TERMCAP_so=$'\e[01;31m';
export LESS_TERMCAP_ue=$'\e[00;00m';
export LESS_TERMCAP_us=$'\e[01;32m';
Last edited by quarkup (2009-03-20 21:19:17)
If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.
Offline
Generally you can feed color codes through less -R. However this appears not to work with pacman-color.
This is what I found here (on an xterm).
pacman-color -Ss kde4 produces colored output
pacman-color -Ss kde4 | less -R produces b/w output
However:
yaourt -Ss kde4 | less -R produces colored output
I do not have the time now to view the pacman-color script. Does anyone know how it does handle colors?
Last edited by bernarcher (2009-03-21 00:26:11)
To know or not to know ...
... the questions remain forever.
Offline
@bernarcher: Or specifically, does an app exist that can fool a program into thinking it is outputting to a tty?
e.g.
ls --color=auto gives color
ls --color=auto | less gives no color
faketty ls --color=auto | less would give color
Last edited by Procyon (2009-03-21 00:48:57)
Offline
faketty ls --color=auto | less would give color
A bit off-topic, but I am completely ignorant of faketty.
It is a kernel module, right? I just can't find suitable info (did some simple google search only).
BTW: ls -l --color=auto works, ls -l --color=auto | less -R does not.
Looks like I am missing some in-depth understanding of how color control works with less. Are there any docs about this topic?
To know or not to know ...
... the questions remain forever.
Offline
No, I was wondering if something exists that could do that, I don't know of any faketty program. Well it's not a big deal of course.
The color control is not about less, but it is ls that knows it is outputting to a pipe, and then decides to strip all colors from output.
Offline
ls --color=auto means: show colors if stdout is a terminal, if the output is(sent into) a pipe, don't use colors.
you have to use the always flag if you always want colors... same behaviour in grep and some other tools too if i recall correctly.
btw, this is in info documentation(for colored info docs, use pinfo). 'pinfo ls'
Last edited by test1000 (2009-03-21 10:57:36)
KISS = "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - Albert Einstein
Offline
ls --color=auto means: show colors if stdout is a terminal, if the output is(sent into) a pipe, don't use colors.
you have to use the always flag if you always want colors... same behaviour in grep and some other tools too if i recall correctly.
btw, this is in info documentation(for colored info docs, use pinfo). 'pinfo ls'
--color=always This was it!
I always did alias to ls='ls --color=auto', although I should have known better, having read man ls, info ls so many times.
When feeding through less, remember to allow raw control codes, though.
ls -l --color=always | less -R
does its coloring job.
Ah, well, another topic to remember firmly. Thanks!
Last edited by bernarcher (2009-03-21 12:39:25)
To know or not to know ...
... the questions remain forever.
Offline
Pages: 1