博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ag (the_silver_searcher) 安装使用
阅读量:5154 次
发布时间:2019-06-13

本文共 2311 字,大约阅读时间需要 7 分钟。

if (I am a Programmer || I have a strong sense of time) I use ag


1. 安装命令行ag(代码中行首的“\”是多余的)

\#!/usr/bin/env bash\#Author Leslie Guan\#make sure you have the root permission\#Usage . install_ag.shset -xTEMP_DIR=$(mktemp -d Leslie.Guan.XXXXXX)cd ${TEMP_DIR}wget https://github.com/ggreer/the_silver_searcher/archive/master.zipTAR_DIR=$(unzip *.zip)TAR_DIR=${TAR_DIR%%/*}TAR_DIR=${TAR_DIR##*:}cd ${TAR_DIR}apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev --force-yes./build.sh && make installcd ../../rm -rf ${TEMP_DIR}ag -Vset +x

ubuntu13.10以后可以直接运行

apt-get install silversearcher-ag

2. 安装Vim插件(必须先安装ag命令行工具)(代码中行首的“\”是多余的)

\#!/usr/bin/env bash\#Author Leslie Guan\#make sure you have the root permission\#Usage . install_Ag4Vim.shset -xTEMP_DIR=$(mktemp -d Leslie.Guan.XXXXXX)cd ${TEMP_DIR}wget https://github.com/rking/ag.vim/archive/master.zipTAR_DIR=$(unzip *.zip)TAR_DIR=${TAR_DIR%%/*}TAR_DIR=${TAR_DIR##*:}cd ${TAR_DIR}cp cp {plugin,autoload,doc} /usr/share/vim/vimcurrent/ -rf cd ../../rm -rf ${TEMP_DIR}                                                                                                                                            set +x

3. 使用

命令行使用

ag HelloWorldag HelloWorld path/to/search
Ag HelloWorldAg HelloWorld path/to/search

在Ag查找出来的quickfix窗口中,你可以使用下列命令:

e    to open file and close the quickfix windowo    to open (same as enter)go   to preview file (open but maintain focus on ag.vim results)t    to open in new tabT    to open in new tab silentlyh    to open in horizontal splitH    to open in horizontal split silentlyv    to open in vertical splitgv   to open in vertical split silentlyq    to close the quickfix window

详细使用方法请查看帮助:

man ag

4. Why ag

速度对比ag>ack>grep

在android全部源码中查找(测试环境20线程32GB内存):

time ag -i activityreal    2m42.568suser    0m16.049ssys 1m29.358s
time ack -i activityreal    5m17.780suser    1m35.830ssys 0m17.521s
time grep -Hrni activity .real    49m27.518suser    43m13.918ssys 0m38.178s

It searches code about 3–5× faster than ack.It ignores file patterns from your .gitignore and .hgignore.If there are files in your source repo you don't want to search, just add their patterns to a .agignore file. *cough* extern *cough*The command name is 33% shorter than ack!

转载于:https://www.cnblogs.com/GMCisMarkdownCraftsman/p/3795315.html

你可能感兴趣的文章
uwsgi基础——SNMP
查看>>
八皇后问题
查看>>
java1.8 Stream
查看>>
day①:集合
查看>>
ring0 与 ring3 层之间的交互
查看>>
黑马程序员——Java基础(一)
查看>>
暑假第七周进度总结
查看>>
原码反码补码
查看>>
Java - Stack源码解析
查看>>
Java - 生产者消费者问题
查看>>
Android - Dalvik 和 JVM区别
查看>>
springboot linux启动方式
查看>>
NYOJ--513--A+B Problem IV(大数)
查看>>
剑指offer--38.左旋转字符串
查看>>
爬虫 scrapy图片下载
查看>>
学习笔记-任意用户密码重置10钟常见姿势
查看>>
msf假冒令牌
查看>>
留着看
查看>>
Centos7 搭建sonarQube
查看>>
mysql中计算两个日期的时间差函数TIMESTAMPDIFF用法
查看>>