1 # Branch: displays the current Git or Mercurial branch fast.
2 # Victor Torres <vpaivatorres@gmail.com>
5 function branch_prompt_info() {
6 # Start checking in current working directory
7 local branch="" dir="$PWD"
8 while [[ "$dir" != '/' ]]; do
10 if [[ -d "${dir}/.git" ]]; then
11 branch="${"$(<"${dir}/.git/HEAD")"##*/}"
12 echo '±' "${branch:gs/%/%%}"
17 if [[ -d "${dir}/.hg" ]]; then
18 if [[ -f "${dir}/.hg/branch" ]]; then
19 branch="$(<"${dir}/.hg/branch")"
24 if [[ -f "${dir}/.hg/bookmarks.current" ]]; then
25 branch="${branch}/$(<"${dir}/.hg/bookmarks.current")"
28 echo '☿' "${branch:gs/%/%%}"
32 # Check parent directory