xargs with command that open editor leaves shell in weird state

前端 未结 5 973
爱一瞬间的悲伤
爱一瞬间的悲伤 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 05:11

    If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you should be able to do this:

    cat projectPaths |
    parallel -uj1 git --git-dir={}/.git --work-tree={} commit -a
    

    In general this works too:

    cat filelist | parallel -Xuj1 $EDITOR
    

    in case you want to edit more than one file at a time (and you have set $EDITOR to your favorite editor).

    -o for xargs (as mentioned elsewhere) only works for some versions of xargs (notably it does not work for GNU xargs).

    Watch the intro video to learn more about GNU Parallel http://www.youtube.com/watch?v=OpaiGYxkSuQ

提交回复
热议问题