使用 git grep 时自动换行
我正在尝试从终端运行 git grep (使用 Titanium)。结果不会换行并在窗口处被切断,因此我无法读取任何内容。我尝试乱搞配置,但什么也没得到。我怎样才能使这些 grep 结果换行?
I am trying to run git grep from terminal (using Titanium). The results do not wrap and get cut off at the window so I cannot read anything. I tried messing around with config but could not get anything. How can I make these grep results wrap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在
.gitconfig
中设置了core.pager
?如果您使用less
,您可以通过按键盘上的右箭头键看到额外的字符。编辑:即使当我取消设置
core.pager
时,git grep
似乎默认会调用less -S
。编辑 2: 糟糕,正如 Keith Thompson 指出的那样,
less
默认情况下会换行。从手册页:Have you set
core.pager
in your.gitconfig
? If you are usingless
, you can see the extra characters by pressing the right arrow key on the keyboard.Edit: Even when I unset
core.pager
,git grep
seems to invokeless -S
by default.Edit 2: Whoops, as Keith Thompson pointed out
less
does wrap lines by default. From the man page:尝试通过
cat
管道输出。Try piping the output through
cat
.有了像 less 这样的分页器,
git grep
已经能够将选项传递给所述寻呼机:从 git 2.0.1(2014 年 6 月 25 日)开始,它也适用于不区分大小写的
git grep
。请参阅 提交 f7febbe 来自 约翰内斯·辛德林 (
dscho
):git grep -O -i
:如果寻呼机为“less
”,则传递“-I
”选项唉,这对于不区分大小写的匹配来说是不正确的,
IE
With a pager like less,
git grep
was already able to pass options to said pager:Starting git 2.0.1 (June 25th, 2014), that also also work with case insensitive
git grep
.See commit f7febbe from Johannes Schindelin (
dscho
):git grep -O -i
: if the pager is 'less
', pass the '-I
' optionAlas, that doesn't do the right thing for a case-insensitive match,
i.e.