title: How Do I Display My Git Branch In My Terminal & Have It Automatically Update?
body: <p>I am trying to have my terminal display my current/active working branch. Everything works as I intend besides the branch update, It is static. When I call ~/.bashrc or ~/.bash_profile it will update my active branch.</p>
  <pre><code># Pre-set colored text.
  orange=$(tput setaf 166); # Orange Text Call
  yellow=$(tput setaf 228); # Yellow Text Call
  red=$(tput setaf 001); # Red Text Call
  blue=$(tput setaf 004); # Blue Text Call
  pink=$(tput setaf 005); # Pink Text Call
  teal=$(tput setaf 006); # Teal Text Call
  green=$(tput setaf 71); # Green Text Call
  white=$(tput setaf 15); # White Text Call
  bold=$(tput bold); # Bold Text Call
  reset=$(tput sgr0); # Reset Call
  
  # Display current git branch in terminal.
  git_branch() {
  git branch 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
  }
  
  PS1=&quot;\[${bold}\]\n&quot;; # Display terminal text in BOLD &amp; fresh line.
  PS1+=&quot;\[${blue}\] Branch:&quot; # Display &quot;Branch:&quot; text.
  PS1+=&quot;\[${orange}\]$(git_branch) &quot; # Call git_branch to be displayed.
  PS1+=&quot;\[${blue}\]User:&quot; # Display &quot;User:&quot; text.
  PS1+=&quot;\[${orange}\]\u &quot;; # Display active user.
  PS1+=&quot;\[${blue}\]Host:&quot;; # Display &quot;Host:&quot; text.
  PS1+=&quot;\[${orange}\]\h &quot;; # Display active host.
  PS1+=&quot;\[${blue}\]Directory:&quot;; # Display &quot;Directory:&quot; text.
  PS1+=&quot;\[${orange}\]\W &quot;; # Display working directory path.
  PS1+=&quot;\n&quot;; # Create a new line to write on.
  PS1+=&quot;\[${white}\]-&gt; \[${reset}\]&quot;; # Display &quot;$&quot; &amp; Color reset.
  
  export PS1; # Export file to be used in terminal (source ~/.bashrc).
  </code></pre>