使用命令xargs的打开编辑器外壳留下怪异状态 [英] xargs with command that open editor leaves shell in weird state

查看:161
本文介绍了使用命令xargs的打开编辑器外壳留下怪异状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个别名犯几个不同的Git项目。我想是这样

I tried to make an alias for committing several different git projects. I tried something like

cat projectPaths | \
xargs -I project git --git-dir=project/.git --work-tree=project commit -a

其中projectPaths是包含路径所有我要提交的项目文件。这似乎在大多数情况下工作,发射了顺序六对每一个项目,这样我可以写一个承诺味精它。我这样做,但是,得到一个消息:

where projectPaths is a file containing the paths to all the projects I want to commit. This seems to work for the most part, firing up vi in sequence for each project so that I can write a commit msg for it. I do, however, get a msg:

Vim:警告:输入不是从终端

"Vim: Warning: Input is not from a terminal"

和后来我的终端是怪异:它不显示我打字和似乎并没有任何输出换行的文本。当我输入复位的东西pretty多恢复正常,但很明显我做错了什么。

and afterward my terminal is weird: it doesn't show the text I type and doesn't seem to output any newlines. When I enter "reset" things pretty much back to normal, but clearly I'm doing something wrong.

有没有一些方法来获得相同的行为不搞乱我的壳?

Is there some way to get the same behavior without messing up my shell?

谢谢!

推荐答案

现在的问题是,既然你正在运行xargs的(因此Git和因此VIM)的管道,它的标准输入从<$ C的输出取$ C>猫projectPaths ,而不是终端;这是混淆了活力。幸运的是,解决方法很简单:用输入从/ dev / tty的添加 -o 标志xargs的,它会开始混帐(因此VIM),而不是它自己的标准输入。

The problem is that since you're running xargs (and hence git and hence vim) in a pipeline, its stdin is taken from the output of cat projectPaths rather than the terminal; this is confusing vim. Fortunately, the solution is simple: add the -o flag to xargs, and it'll start git (and hence vim) with input from /dev/tty, instead of its own stdin.

这篇关于使用命令xargs的打开编辑器外壳留下怪异状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆