ag,grep, ack

来源:互联网 发布:org.apache.cxf包冲突 编辑:程序博客网 时间:2024/04/28 11:13

转自:http://www.cnblogs.com/hanleilei/p/4024154.html?utm_source=tuicool&utm_medium=referral
http://www.cnblogs.com/274914765qq/p/4740498.html

安裝 ag 这个比 grep, ack 还快的玩意

brew install the_silver_searcher

# 安裝过程中可能会出现如下所示的错误
checking for style of include used by make… GNU
checking dependency style of cc… none
checking whether make supports nested variables… yes
./configure: line 3911: syntax error near unexpected token PCRE,'
./configure: line 3911:
PKG_CHECK_MODULES(PCRE, libpcre)’

Error: the_silver_searcher did not build
Logs: /Users/[用戶]/Library/Logs/Homebrew/the_silver_searcher/
Help: https://github.com/mxcl/homebrew/wiki/troubleshooting

# 解決方法,重新建立 PKG 的软链接,并且重新安装
brew link pkg-config
brew install the_silver_searcher

# 如果还不行,就
source ~/.bash_profile 或 csh && bash
brew link pkg-config
brew install the_silver_searcher

# 简单测试一下,搜寻当前目录内的某些关键字
#参数都很像 ack,不过好像沒有 .ackrc?
ag [someWords]
ag -a -S [someWords]

Grep 里面要无视某些目录

# 但 –e
xclude-dir=dir 需要 GNU Grep >= 2.5.2
grep -ri –exclude-dir=.git [someWords] *.java

# 來玩一下 ACK 这东西
# 安裝和使用
brew install ack
ack –java –no-heading [someWords]

# 关于颜色这方面的查看
网址: http://perldoc.perl.org/Term/ANSIColor.html
里面: Function Interface 里面
- recognized normal foreground color
- recognized normal background color

# 简单设定一下
echo “–smart-case” >> ~/.ackrc
echo “–heading” >> ~/.ackrc
echo “–flush” >> ~/.ackrc
echo “–color-line=lightblue” >> ~/.ackrc
echo “–color-match=on_blue” >> ~/.ackrc
echo “–all-types” >> ~/.ackrc

# 最后就可以简化执行
ack –java [someWords]

0 0