[Ilugc] using cat to print in a color scheme
eerpini at gmail.com
Tue Feb 17 08:30:28 IST 2009
Hi steve, ..
that still seems to open the editor , though it reads from the STDIN,
it still opens the editor, which was not exactly what I was looking
I indeed found a better tool, it is called "highlight", ..... A
source code formatter( can be found in the Fedora repos). the
following does the needful for me :
highlight <somefile> -M --style=vim.
anyway that was a nice hack,
On 2/17/09, steve <steve at lonetwin.net> wrote:
> Hi Satish,
> Satish Eerpini wrote:
>> Is it possible to 'cat' a file to the terminal in a particular color
>> scheme, say like the color scheme used by vim or something.
>> I mean instead of getting plain text when we run say :
>> cat foo.c
>> , can we obtain the output in a particular color scheme in the
>> terminal ? Is this possible ??
> Well, "cat" a tool for concatenating files. It does not know (or care) where
> is cat-ing to (for that matter, it does not know or care, where it is
> from either -- and still, or probably because of this, it is one of the most
> useful commands in the unix toolbox)
> OTOH, Pagers (like 'more' or 'less') are tools to view files on the
> That said, vim also behaves somewhat like a pager when invoked using the
> 'view'. However, this does not do syntax highlighting, nor does it take
> from stdin (ie: executing "cat /some/file | view" does not do what you
> So, to view a file with syntax highlighting, you can use a vim trick.
> - Look for the file /usr/share/vim/vim*/macros/less.sh
> - create an alias for that script:
> $ alias vless='/usr/share/vim/vim<version>/macros/less.sh'
> (you may also save the alias in ~/.bashrc if you like)
> - now use vless as you would use less
> $ vless foo.c
> $ cat /some/file | some_filter | vless
> - steve
> Linux Centric Marketplace: http://www.tuxcompatible.com
> To unsubscribe, email ilugc-request at ae.iitm.ac.in with
> "unsubscribe <password> <address>"
> in the subject or body of the message.
More information about the ilugc