开发者

debian ubuntu: most pager does not print the required foreground colors

Need

Within a Debian/Ubuntu OS, I need to print (to STDOUT) a file with embed format interprated by the pager (I'm using "most") but it does not interpolate colors properly. All foreground colors appear white colored even if defined as black or red or green or whatever in the file. I can't find the pager setup to force the use of the file formats.

Questions :

Is there an option to force the pager "most" to using the file formats ?

or

Shall I use another pager (than currently "most") ?

Some details : myfile content exampl开发者_Python百科e :

481\tparameter.foo.bar\t\033[1;32m\033[40m10.0.0.0/255.0.0.0, 172.16.0.0/255.240.0.0\t\033[1;31m\033[40m10.0.0.0/255.0.0.0,192.168.0.0/255.255.255.0\033[00m\n    

Works (colors are correctly interpreted when not using the pager)

echo -e $(cat myfile)  

Does not work (foreground colors appear white using the pager "most")

echo -e $(cat myfile) | most  

or

echo -e $(cat myfile) | pager  


This is the solution I devised to get file coloring in the shell. First, install the package source-highlight

    alex@dionisos:wikimodels$ sudo apt-get install source-highlight

Then create a script named colorcat with the following content

    #!/bin/sh
    /usr/share/source-highlight/src-hilite-lesspipe.sh $*

and save it on your $PATH. I used ~/bin for that but /usr/local/bin is also a good choice.

Make the colorcat script executable

    alex@dionisos:wikimodels$ chmod +x ~/bin/colorcat

And then just do

    alex@dionisos:wikimodels$ colorcat Comments.scala | most

and it will be shown with pretty colors.

You can also do

    alex@dionisos:wikimodels$ colorcat Comments.scala

for small files if you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜