git finish helper script delete current branch and update master

When I finished working on feature branch. I can do

(BRANCH) $ git finish
cleaning up BRANCH
Sure (y/n) ? y
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Deleted branch BRANCH (was 5a868ef).
Pruning origin
...
Successfully rebased and updated refs/heads/master.
(master) $

Put this script to /usr/local/bin/git-finish

#!/bin/bash
branch_name=$(git branch | grep \* | cut -d ' ' -f2)
echo "cleaning up $branch_name"
echo -n "Sure (y/n) ? "
read input < /dev/tty
if [ "$input" == "y" ]; then
git checkout master
git branch -D $branch_name
git remote prune origin
git fetch origin
git pull --rebase --autostash
fi