Guest User

Untitled

a guest
Nov 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. git_branch() {
  2. branch=
  3. gitlabel="git."
  4. if [ -d .git ]; then
  5. status=$(git status 2> /dev/null)
  6. branch="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
  7. if [ "$( echo $status | grep "branch is ahead")" ]; then
  8. branch="$branch*"
  9. fi
  10. if [ "$( echo $status | grep "working tree clean")" ]; then
  11. branch="$gitlabel\033[32m$branch\033[m"
  12. else
  13. branch="$gitlabel\033[93m$branch\033[m";
  14. fi
  15. fi
  16.  
  17. if ! [ -z "$branch" ]; then echo -e " $branch"; fi
  18. }
  19.  
  20. PS1="\W\$(git_branch) $ "
Add Comment
Please, Sign In to add comment