set_prompt () {
    Last_Command=$? # Must come first!
    Blue='\[\e[01;34m\]'
    Grey='\[\e[02;37m\]'
    White='\[\e[01;37m\]'
    Red='\[\e[01;31m\]'
    Green='\[\e[01;32m\]'
    Reset='\[\e[00m\]'
    FancyX='\342\234\227'
    Checkmark='\342\234\223'
    Yellow='\[\e[01;33m\]'
    # Add a bright white exit status for the last command
    PS1="\n$White\# "
    # If it was successful, print a green check mark. Otherwise, print
    # a red X.
    if [[ $Last_Command == 0 ]]; then
        PS1+="$Green$Checkmark "
    else
        PS1+="$Red$FancyX "
    fi
    PS1+="$Blue"
    WORKDIR="$(pwd)"
    LINE=""
    firstline=true
    IFS='/' read -ra FOLDERARRAY <<< "$WORKDIR"
    for item in "${FOLDERARRAY[@]}"; do
      if [ "$item" == "" ]; then
        continue
      fi
      if (( $(( ${#LINE} + ${#item} )) < ((`tput cols` - 10 )) )); then
        LINE+="/${item}"
      else
        if [ "$firstline" != true ]; then
          PS1+="     "
        else
          firstline=false
        fi
        PS1+="${LINE}/.\n"
        LINE="/${item}"
      fi
    done
    if [ "$firstline" != true ]; then
      PS1+="     "
    fi
    PS1+="$LINE\n"
    # If root, just print the host in red. Otherwise, print the current user
    # and host in green.
    if [[ $EUID == 0 ]]; then
        PS1+="$Red\\h "
    else
        PS1+="$Red\\u${Grey}@${Reset}${Green}\\h "
    fi
    PS1+="$Yellow[\t] ${White}> $Reset"
}
PROMPT_COMMAND='set_prompt'
