Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== show current branch in bash prompt ====== Modify your .bash_profile (or .profile) to include a bash function, then change your prompt:<code bash> # git related function to show the current branch with minimal system load; # note that some may prefer to list this with git-symbolic-ref, but not all # systems are set up that way, while git symbolic-ref should always work function parse_git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return echo "("${ref#refs/heads/}")" } # example of my current prompt PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$(parse_git_branch)\$ " </code> This is what it might look like:<code> username@hostname /path/to/some/project (testing)$ </code> ===== External Links ===== * http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/ docs/git/show_current_branch_in_bash_prompt.txt Last modified: 2011/12/14 15:32by billh