Saturday, November 23, 2013

Re: How to pipe colored output to vim and show it correctly?

On Nov 23, 2013, at 6:07 PM, Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi
>
> I have the following alias which works fine when uncolored input.
>
> ~/linux/test/gnu/ack-grep/--color$ alias less
> alias less='vim -R -'
>

> […]
>
> 1 ^[[1;32mtest1.txt^[[0m:^[[1;33m1^[[0m:^[[30;43mA^[[0mBC^[[0m^[[K
> 2 ^[[1;32mtest2.txt^[[0m:^[[1;33m1^[[0m:^[[30;43mA^[[0mXY^[[0m^[[K


I'm unable to reproduce your problem, seems like whenever I pipe something in my shell the ansi escapes are stripped… maybe one of the zsh magic tricks? I don't know

Anyway, something like

alias less='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | vim -R -'

should work (not tested)

--
Gabriele Lana
contact me at gabrielelana at cleancode dot it
http://www.cleancode.it - what we do and what we believe in
http://www.gabrielelana.it - agile methodologies and programming

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: