Guest User

Untitled

a guest
Feb 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # load less configuration for colored man pages if it exists
  2. [ -r ~/.lessrc ] && source ~/.lessrc
  3.  
  4.  
  5. __make_last_cmd_status ()
  6. {
  7. [ $1 -ne 0 ] && printf "%s%s%s%s " \
  8. $(tput bold) \
  9. $(tput setaf 1) \
  10. $1 \
  11. $(tput sgr0)
  12. }
  13.  
  14.  
  15. __make_prompt_user_char ()
  16. {
  17. printf "%s%s%s%s" \
  18. $(tput bold) \
  19. $(tput setaf $([ $EUID -eq 0 ] && printf 1 || printf 4)) \
  20. "\\\$" \
  21. $(tput sgr0)
  22. }
  23.  
  24.  
  25. __choose_prompt_command ()
  26. {
  27. if [ -z "$(type -t __git_ps1)" ]; then
  28. PS1=$(printf "%s%s %s " \
  29. "$(__make_last_cmd_status $1)" \
  30. "\\w" \
  31. "$(__make_prompt_user_char)")
  32. else
  33. GIT_PS1_SHOWDIRTYSTATE=1
  34. GIT_PS1_SHOWSTASHSTATE=1
  35. GIT_PS1_SHOWUNTRACKEDFILES=1
  36. GIT_PS1_SHOWCOLORHINTS=1
  37.  
  38. __git_ps1 "$(printf "%s%s" \
  39. "$(__make_last_cmd_status $1)" \
  40. "\w ")" \
  41. "$(__make_prompt_user_char) " \
  42. "(%s) "
  43. fi
  44. }
  45.  
  46.  
  47. PROMPT_COMMAND='__choose_prompt_command $?'
Add Comment
Please, Sign In to add comment