title: sh: parse_git_branch: command not found
body: <p>I have root enabled on osx El Captain. I tried some of the solution already provided on <a href="https://stackoverflow.com/questions/17811327/git-branch-name-in-prompt">stackoverflow</a> and <a href="https://superuser.com/questions/569455/function-defined-in-my-users-bashrc-causes-an-error-when-i-sudo-su">supersu</a> but couldn't fix the error. I exported <code>function parse_git_branch()</code> to <code>.bash_profile</code> from <code>.bash_prompt</code> but I still get this error. I don't know bash scripting so I have no idea what's going on and what is to be fixed. </p>
  
  <pre><code>abhimanyuaryan at Macbook in ~
  $ sudo su
  sh: parse_git_branch: command not found
  root at Macbook in /Users/abhimanyuaryan
  </code></pre>
  
  <p>.bash_profile </p>
  
  <pre><code>if which rbenv &gt; /dev/null; then eval "$(rbenv init -)"; fi
  
  # Add Homebrew `/usr/local/bin` and User `~/bin` to the `$PATH`
  PATH=/usr/local/bin:$PATH
  PATH=$HOME/bin:$PATH
  export PATH
  
  # Load the shell dotfiles, and then some:
  # * ~/.path can be used to extend `$PATH`.
  # * ~/.extra can be used for other settings you don’t want to commit.
  for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
    [ -r "$file" ] &amp;&amp; source "$file"
  done
  unset file
  </code></pre>
  
  <p>.bash_prompt</p>
  
  <pre><code># @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
  # Shamelessly copied from https://github.com/gf3/dotfiles
  # Screenshot: http://i.imgur.com/s0Blh.png
  
  if [[ $COLORTERM = gnome-* &amp;&amp; $TERM = xterm ]] &amp;&amp; infocmp gnome-256color &gt;/dev/null 2&gt;&amp;1; then
    export TERM=gnome-256color
  elif infocmp xterm-256color &gt;/dev/null 2&gt;&amp;1; then
    export TERM=xterm-256color
  fi
  
  if tput setaf 1 &amp;&gt; /dev/null; then
    tput sgr0
    if [[ $(tput colors) -ge 256 ]] 2&gt;/dev/null; then
      # Changed these colors to fit Solarized theme
      MAGENTA=$(tput setaf 125)
      ORANGE=$(tput setaf 166)
      GREEN=$(tput setaf 64)
      PURPLE=$(tput setaf 61)
      WHITE=$(tput setaf 244)
    else
      MAGENTA=$(tput setaf 5)
      ORANGE=$(tput setaf 4)
      GREEN=$(tput setaf 2)
      PURPLE=$(tput setaf 1)
      WHITE=$(tput setaf 7)
    fi
    BOLD=$(tput bold)
    RESET=$(tput sgr0)
  else
    MAGENTA="\033[1;31m"
    ORANGE="\033[1;33m"
    GREEN="\033[1;32m"
    PURPLE="\033[1;35m"
    WHITE="\033[1;37m"
    BOLD=""
    RESET="\033[m"
  fi
  
  export MAGENTA
  export ORANGE
  export GREEN
  export PURPLE
  export WHITE
  export BOLD
  export RESET
  
  function parse_git_dirty() {
    [[ $(git status 2&gt; /dev/null | tail -n1) != *"working directory clean"* ]] &amp;&amp; echo "*"
  }
  
  function parse_git_branch() {
    git branch --no-color 2&gt; /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
  }
  
  export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2&gt; /dev/null) ]] &amp;&amp; echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
  export PS2="\[$ORANGE\]→ \[$RESET\]"
  </code></pre>