xargs with command that open editor leaves shell in weird state

前端 未结 5 887
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 04:27

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/.gi         


        
5条回答
  •  遇见更好的自我
    2021-02-04 04:54

    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.

提交回复
热议问题