---
title: "show git branch in your bash prompt"
author: "standalone"
date: "2013-07-26T16:47:26Z"
tags: []
categories: ["开源软件"]
slug: "show-git-branch-in-your-bash-prompt"
draft: false
lastmod: "2013-07-26T16:47:26Z"
id: 1914075
url: "https://standalone.iteye.com/blog/1914075"
---

export PS1='\\u\@\\h\ \w\$(parse_git_branch "(%s)")\]\\$\\e[m'

function parse_git_branch {
    ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
    echo "("${ref#refs/heads/}")"
}