• Show git branch on terminal

    Find yourself switching git branches every now and then and hitting git branch just to know what branch you are currently on ? Let your Terminal help you with that. Just paste this to your ~/.bash_profile.

    export PS1="\[\033[00m\]\u@\h\[\033[00m\]:\[\033[00m\]\w\[\033[00m\] \`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[00m\]$\[\033[00m\] "

    This will give you :
    username@computer-name:~/code/project (branch) $

    Go ! Try it out :)


    Leave a Reply