山寨 CGVG

CGVG是08年时同事推荐我的搜索工具,查找速度很快,分为cg和vg两个命令,cg查找关键字,vg可以快速打开cg的搜索结果(通过搜索结果里的序号)。

这个东西完全可以装在Mac上,但macport里却没有,我不想在系统里装一堆没法控制的文件,所以就用BASH函数山寨了一个,最基本的:

cg (){
    grep $1 -rn .
}

这个完全没问题,就是生成的格式难看了了点,所以又用awk完善了一下:

cg () {
    grep "$1" -rn . | awk 'BEGIN {FS=":"};{print "\033[1;31mPath:\033[0;0m "$1     " \033[0;31m"  $2 "\033[0;0m\n=> " $3}'
}

其实完全可以用awk加上trim和关键字高亮的效果,但把这个脚本变得太长就失去我本意了。

2 comments to 山寨 CGVG

  1. liwei says:

    眼花看成 CCAV 了 。。。

  2. @liwei: 你花的太厉害点了

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>