[SOLVED]How to get colorful output when pipe yaourt's STDIO to less?
Hello, second post to NC.
My question is how to get a piped(e.g. pipe yaourt's STDOUT to less) program's colorful output on screen without such option like '--color=always'.
Before post this, I've configured less's default behaviour in "~/.zshrc" with following
less() {
env LESS=R less "$@"
And When I run:
$ dmesg --color=always | less
Everything works fine(I get good, colorful output), but when I run this:
$ yaourt -Qe --date | less
Seems that I can only get grey output on terminal emulator (without 'less' I get colorful output).
Does anyone has idea about getting yaourt's colorful output with 'less' ?
Last edited by izmntuk (2014-06-08 00:15:15)
Thanks for reply and after serveral mintues googling & getting some help from IRC:
It seems that there're some utilities that do not provide such a option like 'color=always', what we need to do is trick these utilities into thinking their's STDIO is to a tty, not a pipe.
1. stdoutisatty way (aur/stdoutisatty-git is needed) from [0]:
$ stdoutisatty yaourt -Qe --date | less
2. socat way (extra/socat is needed, sometimes doesn't work fine) from [1]:
$ socat EXEC:"yaourt -Qe --date",pty STDIO | less
3. script way (sometimes doesn't work fine) from [2]:
$ script -fqc 'yaourt -Qe --date' | less
4. unbuffer way (extra/expect is needed) from [3]:
$ unbuffer yaourt -Qe --date | less
5. zpty way (extra/zsh is needed) slightly modified from [4]:
zmodload zsh/zpty
autoload colors && colors
pty() {
local VERSION=0.2
if [[ -t 0 && $# -ne 0 && ${1} != '--help' ]];then
zpty pty-${UID} ${1+"$@"}
## when piping function pty to a pager, it may be a good idea to disable ^C *in this function*. assume that you're going to run this command: pty ls -alRi --color | less
## and now you enter a pager, and you press the End key by accident, and the pager seems stuck, and to get unstuck you pressed ^C, then the entire function interrupted. so to avoid the interrupt:
if [[ ! -t 1 ]];then
setopt local_traps
trap '' INT
zpty -r pty-${UID}
else
zpty -r pty-${UID}
fi
zpty -d pty-${UID}
elif [[ $# -eq 1 && ${1} == '--version' ]];then
print "pty v${VERSION}"
else
_-automatic-colored
print "${bldblu}Usage: ${bldgrn}pty${rst} ${bldcyn}command${rst} [${bldcyn}argv${rst}...]
wrapper function to run a program under pseudo-terminal
${bldcyn}--help${rst} print help message
${bldcyn}--version${rst} print version"
fi
ptypg() {
if [[ -t 0 && $# -ne 0 && ${1} != '--help' ]];then
pty $@ | pg
else
_-automatic-colored
print "${bldblu}Usage: ${bldgrn}ptypg${rst} ${bldcyn}command${rst} [${bldcyn}argv${rst}...]
wrapper function to run a program under pseudo-terminal and view its output in pg
${bldcyn}--help${rst} print help message"
fi
_-automatic-colored() {
if [[ "${1}" == unset || ! -t 1 ]];then
unset rst bld bldwht bldblk bldred bldgrn bldylw bldblu bldcyn blk red grn ylw blu cyn gry
return 0
elif [[ -t 1 ]];then
rst="${reset_color}"
bld="${fg_bold[default]}"
bldwht="${fg_bold[white]}"
bldblk="$fg_bold[black]"
bldred="$fg_bold[red]"
bldgrn="$fg_bold[green]"
bldylw="$fg_bold[yellow]"
bldblu="$fg_bold[blue]"
bldcyn="$fg_bold[cyan]"
gry="${fg[white]}"
blk="$fg[black]"
red="$fg[red]"
grn="$fg[green]"
ylw="$fg[yellow]"
blu="$fg[blue]"
cyn="$fg[cyan]"
return 0
fi
$ pty yaourt -Qe --date | less
$ ptypg yaourt -Qe --date
And if there are any better implementation please leave a comment add it to wiki .
Last edited by izmntuk (2014-08-19 14:18:45)
Similar Messages
-
Trouble with slow Macbook Air. I have first generation MacBook Air and have a hard time keeping hard drive from being full. After trashing many docs, I have almost 5 gigs available, but mac is slow and I keep getting color wheel when I use Mail. I'd like to install Lion, but now I'm afraid it will slow down my machine even further. Do I have enough free hard disc space? Is Mail problem related to free hard disc space? Thanks for your help!
7gb of free disc space is required to install Lion. Read this about how to free up disc space: http://pondini.org/OSX/DiskSpace.html. Also, advice on how to speed up your mac: http://www.maclife.com/article/feature/25_ways_speed_your_mac
-
Xml: how to get node value when pasing node name as a parameter
Hi,
I've got some xml:
var xmlData:XML =
<1stNode>
<buttonID>first child node value</buttonID>
<imageID>second child node value</imageID>
<labelID>third child node value</labelID>
</1stNode>
Then I want to read specific node value based on a value passed to a function. .
var buttonID = new Button;
var imageID = new Image;
var labelID = new Label;
getNodeValue(buttonID); //the value here is set dynamically
private function getNodeValue (nodeName:String):void {
trace (xmlData.nodeName) //doesn't work
var str:String = "xmlData." + nodeName;
var xml:XMLList = str as XMLList //doesn't work
I'm don't know how to get the value when node name is dynamically changed.use:
getNodeValue(buttonID); //the value here is set dynamically
private function getNodeValue (nodeName:String):void {
trace (xmlData[nodeName]) -
How to get the output of the report in pdf format
how to get the output of the report in pdf format?
Thanks in advance,
madan.Refer these links
http://www.sap-img.com/bc037.htm
http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
CONVERT_ABAPSPOOLJOB_2_PDF FM convert abap spool output to PDF -
How to get the path when i select a directory or a file in a JTree
How to get the path when i select a directory or a file in a JTree
import java.lang.*;
import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.HeadlessException;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Iterator;
* @author Frederic FOURGEOT
* @version 1.0
public class JTreeFolder extends JPanel {
protected DefaultMutableTreeNode racine;
JTree tree;
protected JScrollPane scrollpane;
final static int MAX_LEVEL = 1; // niveau max de descente "direct" dans l'arborescence
* Sous-classe FSNode
* @author Frederic FOURGEOT
* @version 1.0
private class FSNode extends DefaultMutableTreeNode {
File file; // contient le fichier li� au noeud
* Constructeur non visible
private FSNode() {
super();
* Constructeur par initialisation
* @param userObject Object
FSNode(Object userObject) {
super(userObject);
* Constructeur par initialisation
* @param userObject Object
* @param newFile File
FSNode(Object userObject, File newFile) {
super(userObject);
file = newFile;
* Definit le fichier lie au noeud
* @param newFile File
public void setFile(File newFile) {
file = newFile;
* Renvoi le fichier lie au noeud
* @return File
public File getFile() {
return file;
public JTree getJTree(){
return tree ;
* Constructeur
* @throws HeadlessException
public JTreeFolder() throws HeadlessException {
File[] drive;
tree = new JTree();
// cr�ation du noeud sup�rieur
racine = new DefaultMutableTreeNode("Poste de travail");
// cr�ation d'un noeud pour chaque lecteur
drive = File.listRoots();
for (int i = 0 ; i < drive.length ; i++) {
FSNode node = new FSNode(drive, drive[i]);
addFolder(drive[i], node); // on descend dans l'arborescence du lecteur jusqu'� MAX_LEVEL
racine.add(node);
// Gestion d'evenement sur JTree (on �coute les evenements TreeExpansion)
tree.addTreeExpansionListener(new TreeExpansionListener() {
public void treeExpanded(TreeExpansionEvent e) {
// lorsqu'un noeud est ouvert
// on descend dans l'arborescence du noeud jusqu'� MAX_LEVEL
TreePath path = e.getPath();
FSNode node = (FSNode)path.getLastPathComponent();
addFolder(node);
((DefaultTreeModel)tree.getModel()).reload(node); // on recharche uniquement le noeud
public void treeCollapsed(TreeExpansionEvent e) {
// lorsqu'un noeud est referm�
//RIEN
// alimentation du JTree
DefaultTreeModel model = new DefaultTreeModel(racine);
tree.setModel(model);
setLayout(null);
// ajout du JTree au formulaire
tree.setBounds(0, 0, 240, 290);
scrollpane = new JScrollPane(tree);
add(scrollpane);
scrollpane.setBounds(0, 0, 240, 290);
* Recuperation des sous-elements d'un repertoire
* @param driveOrDir
* @param node
public void addFolder(File driveOrDir, DefaultMutableTreeNode node) {
setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
addFolder(driveOrDir, node, 0);
setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
* Recuperation des sous-elements d'un repertoire
* (avec niveau pour r�cursivit� et arr�t sur MAX_LEVEL)
* @param driveOrDir File
* @param node DefaultMutableTreeNode
* @param level int
private void addFolder(File driveOrDir, DefaultMutableTreeNode node, int level) {
File[] fileList;
fileList = driveOrDir.listFiles();
if (fileList != null) {
sortFiles(fileList); // on tri les elements
// on ne cherche pas plus loin que le niveau maximal d�finit
if (level > MAX_LEVEL - 1) {return;}
// pour chaque �l�ment
try {
for (int i = 0; i < fileList.length; i++) {
// en fonction du type d'�l�ment
if (fileList[i].isDirectory()) {
// si c'est un r�pertoire on cr�� un nouveau noeud
FSNode dir = new FSNode(fileList[i].getName(), fileList[i]);
node.add(dir);
// on recherche les �l�ments (r�cursivit�)
addFolder(fileList[i], dir, ++level);
if (fileList[i].isFile()) {
// si c'est un fichier on ajoute l'�l�ment au noeud
node.add(new FSNode(fileList[i].getName(), fileList[i]));
catch (NullPointerException e) {
// rien
* Recuperation des sous-elements d'un noeud
* @param node
public void addFolder(FSNode node) {
setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
for (int i = 0 ; i < node.getChildCount() ; i++) {
addFolder(((FSNode)node.getChildAt(i)).getFile(), (FSNode)node.getChildAt(i));
setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
* Tri une liste de fichier
* @param listFile
public void sortFiles(File[] listFile) {
triRapide(listFile, 0, listFile.length - 1);
* QuickSort : Partition
* @param listFile
* @param deb
* @param fin
* @return
private int partition(File[] listFile, int deb, int fin) {
int compt = deb;
File pivot = listFile[deb];
int i = deb - 1;
int j = fin + 1;
while (true) {
do {
j--;
} while (listFile[j].getName().compareToIgnoreCase(pivot.getName()) > 0);
do {
i++;
} while (listFile[i].getName().compareToIgnoreCase(pivot.getName()) < 0);
if (i < j) {
echanger(listFile, i, j);
} else {
return j;
* Tri rapide : quick sort
* @param listFile
* @param deb
* @param fin
private void triRapide(File[] listFile, int deb, int fin) {
if (deb < fin) {
int positionPivot = partition(listFile, deb, fin);
triRapide(listFile, deb, positionPivot);
triRapide(listFile, positionPivot + 1, fin);
* QuickSort : echanger
* @param listFile
* @param posa
* @param posb
private void echanger(File[] listFile, int posa, int posb) {
File tmpFile = listFile[posa];
listFile[posa] = listFile[posb];
listFile[posb] = tmpFile; -
I cannot see my Iphone 4 in my device window in the finder anymore. It use to appear so I could copy the camera pictures off of it and transfer them to other folders. Does anyone have and idea how to get it back when you plug it in initially. Thanks
You will want to open iPhoto, go to the iPhoto menu and select Preferences. Under the General tab, next to Connecting camera opens: select iPhoto. Close the preferences and quit iPhoto. Reconnect your iPhone 4. iPhoto should open automatically and offer to import your pictures. Import them and then do what you want with them.
Best of luck. -
How to get the output of Standard HR forms in PE51
Hi Experts,
How to get the output of standard HR forms available in PE51 Transaction for coutry grouping 99.
Please advice.
Regards,
IFFHi
Use the t code for country grouping 99....PC00_M99_CEDT - Remuneration Statement. to get the variant in tcode PC00_M99_CALC_SIMU - Simulation.
Like this test for all the standard forms, what all are the available in PE51 for country grouping 99 -
How to get a confirmation when your email is delivered or read ?
With Mail app ,How to get a confirmation when your email is delivered or read?
When I send mail with Mail app , there is flying letter pops up. But now I could not see anymore. Do you know how can I active that animation ?
Thanks for your help -
How to get this output using sql query?
Hi,
How to get this output using sql query?
Sno Name Age ADD Result
1 Anil 23 delhi Pass
2 Shruti 25 bangalor Pass
3 Arun 21 delhi fail
4 Sonu 23 pune Pass
5 Roji 26 hydrabad fail
6 Anil 28 delhi pass
Output
Sno Name Age ADD Result
1 Anil 23 delhi pass
28 delhi passHi Vamshi,
Your query is not pretty clear.
write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
Regards,
Kannan -
How to get the tab when is it pressed?
I have the following situation:
I have an array of JTextField inside a scroollpane. The size of my array is nine or ten depends on some rules. But my window show just four JTextField. So I would like to know how to get the event when I press "tab", just to show the others JTextField while I'm pressing "tab". Because I need this event to scrooll down or scrooll up.
I tried the keylistener, but when I press "tab" any method(keypressed, keyreleased, keytyped) is called.
I also tried the focuslistener. If this event I could scrooll down or scrooll up, but I couldn't do both!!
Can somebody help me??
Thanks anyway!!
GinJTextField implements Scrollable interface, which provides information to the enclosing container such as JScrollPane.
Hence when the tab event is fired, you can compute the Rectangle area that should be visible and then call the 'scrollRectToVisible()' method in JTextField. This will inform the JScrollPane to scroll to the rectangle that you mention.
HTH -
How to get an email when data got inserted
Hi All,
Could you please let me know how to get an email when data got inserted into table by using sql/plsql
Thanks in adavanceCould you please let me know how to get an email when data got inserted into table by using sql/plsql
Well that seems pretty straightforward - write some pl/sql to send you an email when that pl/sql inserts data into a table.
See this Oracle-base article for an example of sending mail.
http://www.oracle-base.com/articles/misc/email-from-oracle-plsql.php
Post what you have tried so far. What part of what you have tried doesn't seem to be working? -
[solved] How to remove color from yaourt output?
Hi everyone,
I am having a problem with removing color output from yaourt.
In order to get a list of installed packages in kdemod-core, I execute the following:
yaourt -Qs ^kdemod | grep kdemod-core | awk '{print $1}' > kdefiles.txt
Some time ago colored output was usually lost when piping commands. For some reason it is not removed anymore so that I get the following file content:
[1;35mkdemod-core/[0m[0m[1mkdemod-kde-common
[...] and so on
Of course pacman doesn't understand this anymore:
pacman -S `cat kdefiles.txt`
Btw. The same options (-Qs ) with pacman search only locally installed packages.
Any ideas?
Thanks,
David
Last edited by dcrabs (2009-05-31 10:47:57)skottish wrote:
dcrabs wrote:Btw. The same options (-Qs ) with pacman search only locally installed packages.
Any ideas?
pacman -Ss searches on-line.
Thanks, but then I don't have the packages that are installed. It is of course much faster and without color but doesn't solve my problem.
Then only thing I could find so far was a statement, that piping through less for example removes color for security reasons. That doesn't seem to be true any more.
There is a col command which outputs plain text but there are still characters left. -
Hi,
I am struggling to get printed output from a professional printing service to match what I see when I softproof on my monitor. The printed image always looks considerably more green and warm, although whites are ok. Blue skies tend to get warm greenish. The printed image often looks like a warm instagram filter had been applied.
I have two (different generation) Dell U2412M monitors (Dell U2412M = Standard gamut = 71% NTSC, 74.3% Adobe RGB, 95.8% sRGB).
These are the steps I have taken to try to achieve color consistency between monitor and print:
I have calibrated and profiled with a Spyder 3 Express using BasICColor Display 5 software, previously also used the Datacolor software that came with the calibrator. After this, what I see on my monitor "looks normal" (skin tones, landscapes etc.)
I shoot RAW with a Sony NEX6, develop in Lightroom 4 using ProPhoto 16 bit color space.
I softproof in Lightroom using an ICC file provided by the printing service.
I use Lightroom to print to file tagging it with AdobeRGB profile. Either as TIFF or as JPG 100%.
I print with the direction to the printer to "not make any auto corrections to my file".
I have Windows 7 64bit.
I thought this would mean that I would get - probably not perfect - but at least a very strong match between softproof and printed image. But I do not.
Are these rather strong color discrepancies to be expected given my hardware?
Is my Spyder broken (it's out of warranty)?
Or is my workflow erroneous?Guermantes wrote:
I am struggling to get printed output from a professional printing service to match what I see when I softproof on my monitor. The printed image always looks considerably more green and warm, although whites are ok. Blue skies tend to get warm greenish. The printed image often looks like a warm instagram filter had been applied.
I have calibrated and profiled with a Spyder 3 Express using BasICColor Display 5 software, previously also used the Datacolor software that came with the calibrator. After this, what I see on my monitor "looks normal" (skin tones, landscapes etc.)
Could be the calibration targets (how you asked to celibate white point etc). Could be the output. Could be the ICC Profile. Could be your file. You have to decide which is which.
Start here: Why Are My Prints Too Dark
Then download a good color reference file like this one: http://www.digitaldog.net/files/2014PrinterTestFileFlat.tif.zip
Soft proof and see if any green or odd color cast appear. If so, probably the profile but use it and have a print made. The output should look good (neutral in neutrals, reds that don't appear yellowish etc).
Generally speaking, if you send Adobe RGB (1998) and the other side assumes it is sRGB, you will end up with desaturated colors. This isn't the fault of Adobe RGB but rather assuming that data is sRGB which it isn't. -
How to get txt output in a column?
Don't know and can't find anywhere, how to get output in a column in a dynamic textfield
instead of getting the output i.e.
output1, output2, output3, etc
I would like to have it as
output1
output2
output3
but I don't know how to make returns in flash - in php /n
can anyone answer my 'simple' question
ThanxI solved it like this and it's working, but it seems silly, because I have 10 dynamic fields like this - I have tried /n to get all the outcome into 1 dynamicfield called total_txt but where and how do I put in /n?
total_txt.text = Number(qty1_txt.text)+ " X " + "art 1"
aAmount_txt.text = Number(qty1_txt.text)+ " X " + "art 1"
bAmount_txt.text = Number(qty2_txt.text)+ " X " + "art 2"
cAmount_txt.text = Number(qty3_txt.text)+ " X " + "art 3"
dAmount_txt.text = Number(qty4_txt.text)+ " X " + "art4"
eAmount_txt.text = Number(qty5_txt.text)+ " X " + "art5"
aprice_txt.text = Number(price1_txt.text) + ",- " +" Euro's"
bprice_txt.text = Number(price2_txt.text) + ",- " +" Euro's"
cprice_txt.text = Number(price3_txt.text) + ",- " +" Euro's"
kprice_txt.text = Number(price4_txt.text) + ",- " +" Euro's"
eprice_txt.text = Number(price5_txt.text) + ",- " +" Euro's" -
How to stop PO output when the indicators are updated with a prog. **URGENT
Hi,
I have developed a update prg which will update the Final invoice indicator and Goods reciept indicator in SRM as well as in R/3 only for 'ORDERED' PO's. This was done using BBP_PO_PD_UPDATE FM. Everything is working fine, all the indicators are getting updated as expected both in SRM and R/3.
Only problem is that when the indicators are updated in SRM, PO Output is getting generated which should not happen.
Do you have any idea how to stop the OUTPUT.
This is very urgent.
BR,
Parvez.PO output
PO Output problems
disable PO output on po change in SRM
Maybe you are looking for
-
Query related to multiple attachments in mail adapter
Hi, I have a query related to multiple attachments in receiver mail adapter. I have successfully configured mail related scenarios but now I have another requirement in which I have multiple source files in one directory and I want to send one mail f
-
Help! My Images in Finder have strange Color Reversals
Ever since installing Leopard on my white 24"iMac, whenever I look at my images in the Finder, all of my bmp's and some jpg's and some tif's appear with the dark colors within them reversed to white - making them appear faded out. This also happens w
-
Transaction key UMB determined on transaction MB1A
Hi experts, I'm having a problem with a goods movement via transaction MB1A. When trying to move material, an error message is displayed with the information that the account does not exist in the chart of accounts. The account in question is configu
-
Problems on Large Network, Limited Administrative Pull
Alright, well I am full of problems here. First let me share the problem. I am on a very large network, over 100 sites, and Tens of thousands of computers, 99% of which are Windows machines. The respect and support for Macs in this school district is
-
Hai all, in a screen i have to assign search help to a field werks but if i double click that field i am taken to a report where that field werks is declared as: data:p_werks type werks_d. but if i derectly execute the screen it is displaying the scr