Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. function parse_git_branch {
  2. ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  3. echo " ("${ref#refs/heads/}")"
  4. }
  5.  
  6. function shortpath {
  7. # How many characters of the $PWD should be kept
  8. local pwd_length=40
  9. local lpwd="${PWD/#$HOME/~}"
  10. if [ $(echo -n $lpwd | wc -c | tr -d " ") -gt $pwd_length ]
  11. then newPWD="...$(echo -n $lpwd | sed -e "s/.*\(.\{$pwd_length\}\)/\1/")"
  12. else newPWD="$(echo -n $lpwd)"
  13. fi
  14. echo $newPWD
  15. }
  16.  
  17. # PS1 prompt color vars
  18. RED="\[\033[1;31m\]"
  19. YELLOW="\[\033[0;33m\]"
  20. GREEN="\[\033[0;32m\]"
  21. WHITE="\[\033[0;37m\]"
  22. PURPLE="\[\033[1;35m\]"
  23. BLUE="\[\033[0;34m\]"
  24. TIME="[\t]"
  25. DIRNAME="\w"
  26.  
  27. export PS1="$PURPLE\$(shortpath)$RED\$(parse_git_branch)$YELLOW ⚡$WHITE "
Add Comment
Please, Sign In to add comment