git branch
の出力をそのまま使おうとすると、current branchを表すマーカーとpaddingが邪魔になります。
$ git branch ... * master ...
sedとか駆使したら消せるんだろうけどgitコマンドだけで完結させられないか、と思ったらformatを指定すればうまくできました。
git branch --format='%(refname:short)'
Stackoverflowに似たような回答がありました。
応用
pecoで絞り込んでswitch
git switch $(git branch --format='%(refname:short)' | peco)
マージ済のブランチをぜんぶ消す
git branch --format='%(refname:short)' | xargs git branch -d