I like the way vim highlights the output from syslog. However, I only want the most recent outputs to be opened. I tried
grep --color=always "$@" /var/log/syslog > /tmp/fileOUT
vim /tmp/fileOUT
but it gives the bash color output like [033;m blah blah. If I don't include --color=always
, there is no color at all. How can I do this? (I'm using bash)
Best Answer
Well,
vim
uses color template files for syntax highlighting. This has nothing to do with the output ofgrep
which uses ANSI escape sequences (the\[033;
stuff you mentioned).My vim doesn't have a style file for syslog and does not color it (I checked both on Debian and on Ubuntu 14.04). If you look at the relevant file on your system, you will find it starts with a regular expression that defines the files to match against. So, if you make your
/tmp/fileOUT
match that syntax, it should be colored. Don't use--color=always
, that will just screw things up.Alternatively, you could use
source-highlight
. Install it withsudo apt-get install source-highlight
and then run:The command above will color the last 50 lines of
/var/log/syslog
: