Ag (the_silver_searcher) 安装使用

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.sh
set -x
TEMP_DIR=$(mktemp -d Leslie.Guan.XXXXXX)
cd ${TEMP_DIR}
wget https://github.com/ggreer/the_silver_searcher/archive/master.zip
TAR_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 install
cd ../../
rm -rf ${TEMP_DIR}
ag -V
set +x

ubuntu13.10以后可以直接运行

apt-get install silversearcher-ag

ag_GitHub

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

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

ag.vim_GitHub

3. 使用

命令行使用

ag HelloWorld
ag HelloWorld path/to/search
Ag HelloWorld
Ag HelloWorld path/to/search

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

e    to open file and close the quickfix window
o    to open (same as enter)
go   to preview file (open but maintain focus on ag.vim results)
t    to open in new tab
T    to open in new tab silently
h    to open in horizontal split
H    to open in horizontal split silently
v    to open in vertical split
gv   to open in vertical split silently
q    to close the quickfix window

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

man ag

4. 对比

速度对比ag>ack>grep

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

time ag -i activity
real    2m42.568s
user    0m16.049s
sys 1m29.358s
time ack -i activity
real    5m17.780s
user    1m35.830s
sys 0m17.521s
time grep -Hrni activity .

What‘s so great about Ag?

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!

Ag (the_silver_searcher) 安装使用

时间: 2024-08-08 13:39:06

Ag (the_silver_searcher) 安装使用的相关文章

Ubutnu安装后要做的10件事

Ubutnu安装后要做的10件事 安装过很多次的Ubuntu,每次都要进行一系列的系统开发环境的配置工作,如安装jdk,配置java环境变量,安装mysql,wine QQ,安装最新的eclipse,下载一些应用软件等,但是很多博文都很零散,每次都得一个一个的找,感觉特别的麻烦,今天在这里整理一下.注意,干货来了!!! 一.首先更新系统 $ sudo apt-get update && sudo apt-get upgrade 二.安装flash player 1.首先下载flash pl

[AlwaysOn Availability Groups]排查AG配置

排查AG配置 本文主要用来帮助排查在AG配置时出现的问题,包括,AG功能被禁用,账号配置不正确,数据库镜像endpoint不存在,endpoint不能访问. Section Description AlwaysOn Availability Groups Is Not Enabled 如果实例没有启动AG特性,实例就不支持任何AG相关的功能 Accounts 在SQL Server在运行的情况下,正确的账号配置 Endpoints 诊断关于实例的镜像endpoint问题. System name

精品:AG 1.3.8 for mac 百度网盘不限速下载软件

下载:AG 1.3.8 + chrome插件 安装方法: 第一步:下载AG 1.3.8 + chrome插件中的chrome.dmg和AG1.3.8安装包: ①打开AG 1.3.8.dmg完成AG的安装(拖动到Applications文件夹进行安装) ②解压chrome.dmg,解压后随便放到一个地方 第二步:配置Chrome浏览器 ①:打开Chrome浏览器,点击偏好设置-扩展程序-勾上”开发者模式“,随后将第一步②中解压后的整个chrome文件夹拖入Chrome浏览器界面,即可完成插件的安装

使用Linux工作之Fedora KDE

小明拿着在Win8下不断蓝屏的T440和公司建议不使用云笔记的规定,心下想着,是时候回归linux了... 一.系统的获取与启动盘的制作 fedora20 KDE版 liveusb-creator将iso文件extract到U盘上,从U盘启动,安装即可 二.安装系统 点击 partition--done--custom partition--LVM--auto create user--make this user as admin 三.系统设置 close bluetooth quit kcl

Linux ag命令

一.简介 Ag是用C++写的,搜索速度快,比grep更有效率. 二.安装 RHEL7+ rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm yum install the_silver_searcher RHEL7- wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/utili

一个比ack速度快n倍的代码搜索工具: ag

一个比ack速度快n倍的代码搜索工具:  ag 银搜索者(The Silver Searcher) 一个类似于代码搜索工具ack,着重于速度. Github:   https://github.com/ggreer/the_silver_searcher Ag有什么好处? 它比一个数量级快ack. 它忽略了你.gitignore和你的文件模式.hgignore. 如果您的源代码中有文件您不想搜索,只需将其模式添加到.ignore文件中即可.(*咳嗽* *.min.js*咳嗽*) 命令名称比起第3

centos7安装docker并设置开机启动

版本要求:查看内核版本,需大于3.10 [[email protected] ~]# uname -r 3.10.0-327.10.1.el7.x86_64 更新内核:如果是生产机器务必慎重更新内核,避免出现不必要的问题. sudo yum update 安装docker [[email protected] ~]# curl -sSL https://get.docker.com/ | sh + sh -c 'sleep 3; yum -y -q install docker-engine'

GitLab安装说明

http://blog.csdn.net/huangzhijie3918/article/details/51330425 GitLab,是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用. gitlab是基于Ruby on Rails的,安装和配置非常麻烦,不过有傻瓜安装包,https://about.gitlab.com/downloads/,或者,https://bitnami.com/stack/gitl

RHEL7.2安装Nagios4.2.1+Cacti0.8.8h

由于公司系统监控(IPMoniter)和网络流量监控(MRTG)分别由不同的软件监控且由几台服务器完成,近期想整合到一起,并改为开源免费的Nagios和Cacti完成.以下为部署日志. 一.安装RHEL7.2 最小化安装,配置IP,时间同步,本地yum源,安装vim(个人习惯).bash-completion(命令补齐) # yum install vim # yum install bash-completion # yum install chrony # systemctl enable