我最近发现git grep并喜欢它的速度,事实上只搜索回购中的文件.但是从未来ack(ack-grep在Ubuntu),一两件事没有被期望是输出格式,这是不幸的是更像grep比ack.去搞清楚.
ack:
另一方面,git grep:
是否有任何git grep选项,或与其他工具组合,可以使git grep输出看起来像ack输出?
tor*_*rek 10
您已经回答了部分问题(--break在文件之间插入一个空行,分别--heading打印文件名,-n或者--line-number在每行上给出行号).
其余的只是颜色选项,通过条目设置git configcolor.grep.<slot>.有关详细信息,请参阅文档,但请注意,根据您的要求,我认为这样做有:
[alias]
ack = -c color.grep.linenumber=\"bold yellow\" \
-c color.grep.filename=\"bold green\" \
-c color.grep.match=\"reverse yellow\" \
grep --break --heading --line-number
Run Code Online (Sandbox Code Playgroud)
(这表达为你看到它,git config --global --edit因为引用是凌乱的).
或者,在一个命令中设置它:
git config --global alias.ack '-c color.grep.linenumber="bold yellow"
-c color.grep.filename="bold green"
-c color.grep.match="reverse yellow"
grep --break --heading --line-number'
Run Code Online (Sandbox Code Playgroud)
添加或减去-c选项以更改您喜欢的颜色,和/或通过设置color.grep.<name> = color而不是使用git ack别名将它们设置为首选默认值.
来自Travis Jeffery 的分组 输出,git grep例如ack:
git config --global alias.g "grep --break --heading --line-number"
Run Code Online (Sandbox Code Playgroud)
然后git g像你一样使用git grep:
git g <search_string>
Run Code Online (Sandbox Code Playgroud)
这与输出并不完全匹配ack——它缺少颜色突出显示——但对于快速解决方案来说这是可以的。
| 归档时间: |
|
| 查看次数: |
659 次 |
| 最近记录: |