swarfega

bash prompt customization

Jan 4th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.14 KB | None | 0 0
  1. #### GIT && PS1
  2. #  SETUP CONSTANTS
  3. #  Bunch-o-predefined colors.  Makes reading code easier than escape sequences.
  4.  
  5. # Reset
  6. Color_Off="\[\033[0m\]"       # Text Reset
  7.  
  8. # Regular Colors
  9. Black="\[\033[0;30m\]"        # Black
  10. Red="\[\033[0;31m\]"          # Red
  11. Green="\[\033[0;32m\]"        # Green
  12. Yellow="\[\033[0;33m\]"       # Yellow
  13. Blue="\[\033[0;34m\]"         # Blue
  14. Purple="\[\033[0;35m\]"       # Purple
  15. Cyan="\[\033[0;36m\]"         # Cyan
  16. White="\[\033[0;37m\]"        # White
  17.  
  18. # Bold
  19. BBlack="\[\033[1;30m\]"       # Black
  20. BRed="\[\033[1;31m\]"         # Red
  21. BGreen="\[\033[1;32m\]"       # Green
  22. BYellow="\[\033[1;33m\]"      # Yellow
  23. BBlue="\[\033[1;34m\]"        # Blue
  24. BPurple="\[\033[1;35m\]"      # Purple
  25. BCyan="\[\033[1;36m\]"        # Cyan
  26. BWhite="\[\033[1;37m\]"       # White
  27.  
  28. # Underline
  29. UBlack="\[\033[4;30m\]"       # Black
  30. URed="\[\033[4;31m\]"         # Red
  31. UGreen="\[\033[4;32m\]"       # Green
  32. UYellow="\[\033[4;33m\]"      # Yellow
  33. UBlue="\[\033[4;34m\]"        # Blue
  34. UPurple="\[\033[4;35m\]"      # Purple
  35. UCyan="\[\033[4;36m\]"        # Cyan
  36. UWhite="\[\033[4;37m\]"       # White
  37.  
  38. # Background
  39. On_Black="\[\033[40m\]"       # Black
  40. On_Red="\[\033[41m\]"         # Red
  41. On_Green="\[\033[42m\]"       # Green
  42. On_Yellow="\[\033[43m\]"      # Yellow
  43. On_Blue="\[\033[44m\]"        # Blue
  44. On_Purple="\[\033[45m\]"      # Purple
  45. On_Cyan="\[\033[46m\]"        # Cyan
  46. On_White="\[\033[47m\]"       # White
  47.  
  48. # High Intensty
  49. IBlack="\[\033[0;90m\]"       # Black
  50. IRed="\[\033[0;91m\]"         # Red
  51. IGreen="\[\033[0;92m\]"       # Green
  52. IYellow="\[\033[0;93m\]"      # Yellow
  53. IBlue="\[\033[0;94m\]"        # Blue
  54. IPurple="\[\033[0;95m\]"      # Purple
  55. ICyan="\[\033[0;96m\]"        # Cyan
  56. IWhite="\[\033[0;97m\]"       # White
  57.  
  58. # Bold High Intensty
  59. BIBlack="\[\033[1;90m\]"      # Black
  60. BIRed="\[\033[1;91m\]"        # Red
  61. BIGreen="\[\033[1;92m\]"      # Green
  62. BIYellow="\[\033[1;93m\]"     # Yellow
  63. BIBlue="\[\033[1;94m\]"       # Blue
  64. BIPurple="\[\033[1;95m\]"     # Purple
  65. BICyan="\[\033[1;96m\]"       # Cyan
  66. BIWhite="\[\033[1;97m\]"      # White
  67.  
  68. # High Intensty backgrounds
  69. On_IBlack="\[\033[0;100m\]"   # Black
  70. On_IRed="\[\033[0;101m\]"     # Red
  71. On_IGreen="\[\033[0;102m\]"   # Green
  72. On_IYellow="\[\033[0;103m\]"  # Yellow
  73. On_IBlue="\[\033[0;104m\]"    # Blue
  74. On_IPurple="\[\033[10;95m\]"  # Purple
  75. On_ICyan="\[\033[0;106m\]"    # Cyan
  76. On_IWhite="\[\033[0;107m\]"   # White
  77.  
  78. # Various variables you might want for your PS1 prompt instead
  79. Time12h="\T"
  80. Time12a="\@"
  81. PathShort="\w"
  82. PathFull="\W"
  83. NewLine="\n"
  84. Jobs="\j"
  85.  
  86. # cow saying your fortune (how awesome is that?)
  87. fortune -s | cowsay
  88.  
  89. #show current project and branch
  90. GIT_PS1_SHOWDIRTYSTATE=false
  91.  
  92. if [[ ${EUID} == 0 ]] ; then
  93.   sq_color=$BRed
  94. else
  95.   sq_color=$BBlue
  96. fi
  97.  
  98. export PS1="\n$sq_color\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[$BRed\342\234\227$sq_color]\342\224\200\")[$IBlack\t$sq_color]\342\224\200[\[\033[01;37m\]\u$sq_color]\342\224\200[$BGreen\w$sq_color]\n$sq_color\342\224\224\342\224\200\342\224\200> $sq_color\$ $Color_Off"
  99.  
  100. alias ls='ls --color=auto'
  101. alias diff='colordiff'
  102.  
  103. unset sq_color
Advertisement
Add Comment
Please, Sign In to add comment