Skip to content

Instantly share code, notes, and snippets.

View Bgouveia's full-sized avatar

bruno gouveia Bgouveia

  • aiqfome
  • Brasil, São Paulo - SP
View GitHub Profile
@Bgouveia
Bgouveia / gist:6917841
Last active December 25, 2015 04:29
Commandline git branch description (NOT MINE, just sharing). Paste at the end of your ~/.bashrc or ~/.profile or ~/.bash_profile (check out which one you have first). After pasting and saving it, type "source ~/.bashrc" (or .profile or .bash_profile) and get inside any repo to check if it worked =)
# git branchs
function find_git_branch {
local dir=. head
until [ "$dir" -ef / ]; do
if [ -f "$dir/.git/HEAD" ]; then
head=$(< "$dir/.git/HEAD")
if [[ $head == ref:\ refs/heads/* ]]; then
git_branch=" (${head#*/*/})"
elif [[ $head != '' ]]; then
git_branch=' (detached)'