Want more features on Pastebin? Sign Up, it's FREE!
Guest

Bash prompt

By: a guest on Feb 27th, 2014  |  syntax: Bash  |  size: 1.92 KB  |  views: 105  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. __git_ps1 ()
  2. {
  3.         local b="$(git symbolic-ref HEAD 2>/dev/null)";
  4.         if [ -n "$b" ]; then
  5.                 printf " (%s)" "${b##refs/heads/}";
  6.         fi
  7. }
  8. export PS1='\
  9. \[\e[01;30m\]\t \
  10. `[ "$(screen -ls | grep -c Detach)" != "0" ]\
  11. && echo "\[\e[00;34m\]$(screen -ls | grep -c Detach ) "`\
  12. `[ "$(jobs -r | wc -l)" != "0" ]\
  13. && echo "\[\e[00;33m\]$(jobs -r | wc -l ) "`\
  14. `[ "$(jobs -s | wc -l)" != "0" ]\
  15. && echo "\[\e[00;31m\]$(jobs -s | wc -l ) "`\
  16. \[\e[01;37m\][\
  17. `[ $UID == 0 -a $USER != $(logname) ]\
  18. && echo "\[\e[00;31m\]"`\
  19. `[ $UID == 0 -a $USER != $(logname) -a -z "$SUDO_USER" ]\
  20. && echo "\[\e[01;31m\]"`\
  21. `[ $UID == 0 -a $USER == $(logname) ]\
  22. && echo "\[\e[01;33m\]"`\
  23. `[ $UID != 0 -a $USER == $(logname) ]\
  24. && echo "\[\e[00;32m\]"`\
  25. `[ $UID != 0 -a $USER != $(logname) ]\
  26. && echo "\[\e[00;33m\]"`\
  27. \u\
  28. \[\e[00;36m\]@\
  29. `[ "$SSH_CLIENT" != "" -o "$SSH2_CLIENT" != "" ]\
  30. && echo "\[\e[00;33m\]"\
  31. || echo "\[\e[00;32m\]"`\
  32. \h \
  33. `[ -w "${PWD}" ]\
  34. && echo "\[\e[01;34m\]\W"\
  35. || echo "\[\e[01;31m\]\W"`\
  36. \[\e[01;37m\]]\
  37. `[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]]\
  38. && echo "\[\e[01;31m\]"\
  39. || echo "\[\e[01;32m\]"`$(__git_ps1 "(%s)")\[\e[00m\]\$ '
  40.                         #time in black  #[,bold white #  user, red   # @, cyan     # host, green   # dir,bold blue# ],bold white#   Check if something needs to be commited in git repo                                    # if so, bold red            #if not, bold green  #current git branch#prompt, normal
  41. # original from https://makandracards.com/makandra/1090-customize-your-bash-prompt
  42. #export PS1='\[\e[01;30m\]\t `if [ $? = 0 ]; then echo "\[\e[32m\]✔"; else echo "\[\e[31m\]✘"; fi` \[\e[00;37m\]\u\[\e[01;37m\]:`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 "(%s)\[\e[00m\]")\[\e[01;34m\]\w\[\e[00m\]\$ '
clone this paste RAW Paste Data