Delete all Git branches which have been merged

I was getting sick of having so many local branches. The following command line will clean them up removing any local branch that has been merged remotely. Exclude branched by adding them to the pipe separated names in brackets (^*|master|dev)

git branch --merged | egrep -v "(^*|master|dev)" | xargs git branch -d