Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. profile
  2.  
  3. export NVM_DIR="$HOME/.nvm"
  4. [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
  5.  
  6. if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
  7. . `brew --prefix`/etc/bash_completion.d/git-completion.bash
  8. fi
  9.  
  10.  
  11. COLOR_RED="\033[0;31m"
  12. COLOR_YELLOW="\033[0;33m"
  13. COLOR_GREEN="\033[0;32m"
  14. COLOR_OCHRE="\033[38;5;95m"
  15. COLOR_BLUE="\033[0;34m"
  16. COLOR_WHITE="\033[0;37m"
  17. COLOR_RESET="\033[0m"
  18.  
  19. function git_color {
  20. local git_status="$(git status 2> /dev/null)"
  21.  
  22. if [[ ! $git_status =~ "working tree clean" ]]; then
  23. echo -e $COLOR_RED
  24. elif [[ $git_status =~ "Your branch is ahead of" ]]; then
  25. echo -e $COLOR_YELLOW
  26. elif [[ $git_status =~ "nothing to commit" ]]; then
  27. echo -e $COLOR_GREEN
  28. else
  29. echo -e $COLOR_OCHRE
  30. fi
  31. }
  32.  
  33. function git_branch {
  34. local git_status="$(git status 2> /dev/null)"
  35. local on_branch="On branch ([^${IFS}]*)"
  36. local on_commit="HEAD detached at ([^${IFS}]*)"
  37.  
  38. if [[ $git_status =~ $on_branch ]]; then
  39. local branch=${BASH_REMATCH[1]}
  40. echo "($branch) "
  41. elif [[ $git_status =~ $on_commit ]]; then
  42. local commit=${BASH_REMATCH[1]}
  43. echo "($commit) "
  44. fi
  45. }
  46.  
  47. PS1="\[$COLOR_WHITE\]\u | \W " # basename of pwd
  48. PS1+="\[\$(git_color)\]" # colors git status
  49. PS1+="\$(git_branch)" # prints current branch
  50. PS1+="\[$COLOR_RESET\]$ " # '#' for root, else '$'
  51. export PS1
  52.  
  53. mergepush() {
  54. currentb="$(git rev-parse --abbrev-ref HEAD)"
  55. echo "Merge and push $currentb -> $1? (enter to continue)"
  56. read -s -n 1 key # -s: do not echo input character. -n 1: read only 1 charac$
  57.  
  58. if [[ $key = "" ]]; then
  59. git checkout $1 && git merge $currentb && git push && git checkout $currentb
  60. else
  61. [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell$
  62. fi
  63. }
  64.  
  65.  
  66.  
  67. rc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement