在git-grep输出中包括列号

art*_*ave 5 git shell

银searcherer--column说是这样的选项:

% ag silver --column               
Brewfile
40:13:install the_silver_searcher
Run Code Online (Sandbox Code Playgroud)

其中13表示匹配(银)开始的列。

有没有办法得到类似的东西git-grep

编辑

原因是我想git-grep用作grepprgvim(在某些情况下,例如node.js项目要快得多)。

art*_*ave 0

这不是我希望的答案,但这里有一个手卷脚本可以做到这一点:

git grep -n $1 | while read git_grep; do

  file_and_line=$(echo "$git_grep" | cut -d: -f1 -f2)
  match=$(echo "$git_grep" | sed 's/[^:]*:[^:]*:\(.*\)/\1/')
  column=$(echo "$match" | awk "{print index(\$0, \"$1\")}")

  echo "$file_and_line:$column:$match"
done
Run Code Online (Sandbox Code Playgroud)

行动:

% ./bin/grepprg.sh silver  
Brewfile:40:13:install the_silver_searcher
Run Code Online (Sandbox Code Playgroud)