문제

I'm trying to clean up my local set of git branches. There are quite a few, and I don't want to do git branch -D branchname for all of them. There's also no pattern that captures all and only the ones I want to kill. Then I remembered that I once saw someone pipe stdout into a buffer editor, and I thought that sounded perfect.

I'd like to take the output of git branch -l, pipe it into nano, edit the buffer, then (upon exiting nano) have the final buffer be supplied as the input into another command (specifically, xargs git branch -D).

Having played around for a while without luck, this has become an academic question related to editing buffers on the fly -- so, no git-specific solutions, please. I want to know how to edit buffers on the fly in bash one-liners, because it seems like the kind of bash-fu that could elevate me to godhood. Acceptable answers should also work when sandwiched between e.g. find and file or path operations (like rm, cat, or grep).

도움이 되었습니까?

해결책

The semi-colon is a perfectly acceptable operator.

git branch -l > /tmp/branches; nano /tmp/branches; whatever /tmp/branches; rm /tmp/branches
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top