Friday, January 20, 2012

"cmore": Colorized text paging using vim...

Sometimes, I want colorized syntax and nice navigation for paging. We can use vim to provide this service. This assumes your terminal client supports the terminal type "xterm-color". If you need another color terminal type, customize accordingly.
  • Install all of the standard vim packages
  • Add alias cmore="TERM=xterm-color vim -R -" to your ~/.profile
  • Add the following [1] to your ~/.vimrc
syntax on
hi Comment ctermfg=Blue guifg=Blue
hi String ctermfg=LightRed guifg=LightRed

  • Reload your profile: source ~/.profile
  • Usage: cat | cmore 
  •  It's vim in read-only mode, so use :q to quit.

[1] I found the default colors to be too dark.

No comments:

Post a Comment