I'm searching through my repository (with vim-fugitive's :Ggrep), I have different .js files - the minified ones and the regular ones.
I would like to omit from git grep
the minified files (in other words - the very long lines that match the query). I looked into git help grep
and googled but couldn't find anything. All ideas are welcomed.
This doesn't actually omit long lines as requested, but to avoid your terminal filling up when a very long line matches (e.g. minified javascript) you can configure git to page the output through less
with the -S
option (short for --chop-long-lines
):
# For current repo only
git config --local core.pager "less -S"
# For all git repos
git config --global core.pager "less -S"
or equivalently add this to the relevant .gitconfig
or .git/config
[core]
pager = less -S