Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
  2. . `brew --prefix`/etc/bash_completion.d/git-completion.bash
  3. fi
  4.  
  5.  
  6. parse_git_has_diff() {
  7. has_diff=false
  8. while read line; do
  9. has_diff=true
  10. break
  11. done < <(git diff --name-only 2>/dev/null)
  12. if [ "$has_diff" = true ]; then
  13. echo " *"
  14. else
  15. echo ""
  16. fi
  17. }
  18.  
  19. parse_git_branch() {
  20. while read -r branch; do
  21. [[ $branch = \** ]] && current_branch=${branch#* }
  22. done < <(git branch 2>/dev/null)
  23.  
  24. [[ $current_branch ]] && printf ' [%s]' "$current_branch"
  25. }
  26.  
  27. _git_cleanup_branches() {
  28. git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
  29. }
  30.  
  31. export PS1="\u@\h \[\033[36m\]\W\[\033[32m\]\$(parse_git_branch)\$(parse_git_has_diff)\[\033[00m\] $ "
  32.  
  33. github() {
  34. REMOTE=$(git remote -v | grep github.com -m 1)
  35. REGEX='github\.com[:/]([^.]+).git'
  36. if [[ $REMOTE =~ $REGEX ]]; then
  37. URL_PATH=${BASH_REMATCH[1]}
  38. URL=https://github.com/"${URL_PATH}"
  39. open $URL
  40. fi
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement