Skip to content

Instantly share code, notes, and snippets.

@dinhvh
Created January 31, 2020 00:57
Show Gist options
  • Save dinhvh/8dd2f851536f8659af0d91d270ef1050 to your computer and use it in GitHub Desktop.
Save dinhvh/8dd2f851536f8659af0d91d270ef1050 to your computer and use it in GitHub Desktop.
#!/bin/bash
branch_name="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)"
bold="$(tput bold)"
normal="$(tput sgr0)"
echo "${bold}Current branch: $branch_name${normal}"
echo ""
git for-each-ref --sort='-committerdate' --format='%(objectname:short) | %(committerdate:human) | %(refname)' refs/heads | sed -e 's/refs\/heads\///' | head -n 20 | while read line ; do
line_branch="$(echo $line|sed -e 's/.* | .* | \(.*\)/\1/')"
if test $line_branch = $branch_name ; then
echo "${bold}$line${normal}"
else
echo "$line"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment