Guest User

Untitled

a guest
Jul 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. ## Terminal Colors
  2. export CLICOLOR=1
  3. export LSCOLORS=ExFxCxDxBxegedabagacad
  4.  
  5. # Git Color Coding
  6. RED="\[\033[0;31m\]"
  7. YELLOW="\[\033[0;33m\]"
  8. GREEN="\[\033[0;32m\]"
  9. BLUE="\[\033[0;34m\]"
  10. LIGHT_RED="\[\033[1;31m\]"
  11. LIGHT_GREEN="\[\033[1;32m\]"
  12. WHITE="\[\033[1;37m\]"
  13. LIGHT_GRAY="\[\033[0;37m\]"
  14. COLOR_NONE="\[\e[0m\]"
  15.  
  16. function parse_git_branch {
  17.  
  18. git rev-parse --git-dir &> /dev/null
  19. git_status="$(git status 2> /dev/null)"
  20. branch_pattern="^# On branch ([^${IFS}]*)"
  21. remote_pattern="# Your branch is (.*) of"
  22. diverge_pattern="# Your branch and (.*) have diverged"
  23. if [[ ! ${git_status}} =~ "working directory clean" ]]; then
  24. state="${RED}⚡"
  25. fi
  26. # add an else if or two here if you want to get more specific
  27. if [[ ${git_status} =~ ${remote_pattern} ]]; then
  28. if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
  29. remote="${YELLOW}↑"
  30. else
  31. remote="${YELLOW}↓"
  32. fi
  33. fi
  34. if [[ ${git_status} =~ ${diverge_pattern} ]]; then
  35. remote="${YELLOW}↕"
  36. fi
  37. if [[ ${git_status} =~ ${branch_pattern} ]]; then
  38. branch=${BASH_REMATCH[1]}
  39. echo " (${branch})${remote}${state}"
  40. fi
  41. }
  42.  
  43. function prompt_func() {
  44. previous_return_value=$?;
  45. # prompt="${TITLEBAR}$BLUE[$RED\w$GREEN$(__git_ps1)$YELLOW$(git_dirty_flag)$BLUE]$COLOR_NONE "
  46. prompt="${TITLEBAR}${BLUE}[${RED}\w${GREEN}$(parse_git_branch)${BLUE}]${COLOR_NONE} "
  47. if test $previous_return_value -eq 0
  48. then
  49. PS1="${prompt}➔ "
  50. else
  51. PS1="${prompt}${RED}➔${COLOR_NONE} "
  52. fi
  53. }
  54.  
  55. PROMPT_COMMAND=prompt_func
Add Comment
Please, Sign In to add comment