Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

bash prompt

By: a guest on Sep 19th, 2012  |  syntax: Bash  |  size: 2.78 KB  |  hits: 32  |  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. #TEXT COLORS
  2. ################################################################################
  3. TXTBLK='\[\e[0;30m\]'           # Black - Regular
  4. TXTRED='\[\e[0;31m\]'           # Red
  5. TXTGRN='\[\e[0;32m\]'           # Green
  6. TXTYLW='\[\e[0;33m\]'           # Yellow
  7. TXTBLU='\[\e[0;34m\]'           # Blue
  8. TXTPUR='\[\e[0;35m\]'           # Purple
  9. TXTCYN='\[\e[0;36m\]'           # Cyan
  10. TXTWHT='\[\e[0;37m\]'           # White
  11. BLDBLK='\[\e[1;30m\]'           # Black - Bold
  12. BLDRED='\[\e[1;31m\]'           # Red
  13. BLDGRN='\[\e[1;32m\]'           # Green
  14. BLDYLW='\[\e[1;33m\]'           # Yellow
  15. BLDBLU='\[\e[1;34m\]'           # Blue
  16. BLDPUR='\[\e[1;35m\]'           # Purple
  17. BLDCYN='\[\e[1;36m\]'           # Cyan
  18. BLDWHT='\[\e[1;37m\]'           # White
  19. UNDBLK='\[\e[4;30m\]'           # Black - Underline
  20. UNDRED='\[\e[4;31m\]'           # Red
  21. UNDGRN='\[\e[4;32m\]'           # Green
  22. UNDYLW='\[\e[4;33m\]'           # Yellow
  23. UNDBLU='\[\e[4;34m\]'           # Blue
  24. UNDPUR='\[\e[4;35m\]'           # Purple
  25. UNDCYN='\[\e[4;36m\]'           # Cyan
  26. UNDWHT='\[\e[4;37m\]'           # White
  27. BAKBLK='\[\e[40m\]'             # Black - Background
  28. BAKRED='\[\e[41m\]'             # Red
  29. BAKGRN='\[\e[42m\]'             # Green
  30. BAKYLW='\[\e[43m\]'             # Yellow
  31. BAKBLU='\[\e[44m\]'             # Blue
  32. BAKPUR='\[\e[45m\]'             # Purple
  33. BAKCYN='\[\e[46m\]'             # Cyan
  34. BAKWHT='\[\e[47m\]'             # White
  35. TXTRST='\[\e[0m\]'              # Text Reset
  36.  
  37. TXT233='\033[38;5;233m'         # Darkest Grey - Regular
  38. TXT238='\033[38;5;238m'         # Darker Grey
  39. TXT000='\033[38;5;000m'         # Dark Grey
  40. TXT088='\033[38;5;088m'         # Dark Red
  41. ERRRED='\033[38;5;196m'         # Bright Red
  42.  
  43. BAK233='\033[48;5;233m'         # Darkest Grey - Background
  44. BAK238='\033[48;5;238m'         # Darker Grey
  45. BAK000='\033[48;5;000m'         # Dark Grey
  46.  
  47. #PROMPT
  48. ################################################################################
  49. # cool prompt stuff
  50. # based on a function found in bashtstyle-ng 5.0b1
  51. # Original author Christopher Roy Bratusek (http://www.nanolx.org)
  52. # Last arranged by zach Tue Jul 24 06:40:19 EDT 2012
  53. function pre_prompt {
  54. specPWD=$(echo -n ${PWD} | sed "s/\/home\/j\/llc\/$USER/~/g")   #Should now properly sed path of current user
  55. newPWD=$specPWD
  56. #let promptsize=$(echo -n "[HH:MM:SS][$USER]@[$HOST][$specPWD]" \ | wc -c | tr -d " ")
  57. let promptsize=$(echo -n "_!___${USER}@${HOSTNAME}__${specPWD}" \ | wc -c | tr -d " ")
  58. let fillsize=(${COLUMNS}+1)-${promptsize}
  59. fill=""
  60. while [ "$fillsize" -gt "0" ]
  61. do
  62. #    fill="${fill}—"
  63.    fill="${fill} "
  64.         let fillsize=${fillsize}-1
  65. done
  66. if [ "$fillsize" -lt "0" ]
  67. then
  68.     let cutt=1-${fillsize}
  69.     newPWD="…$(echo -n $specPWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
  70. fi
  71. }
  72.  
  73. PROMPT_COMMAND=pre_prompt
  74.  
  75. PS1="${ERRRED}${BAK238} \`if [ \$? = 0 ]; then echo \[\e[30m\]\$; else echo "!"; fi\` ${TXT233}${BAKBLK}${TXTGRN}${BAKBLK} \u${BLDBLK}@${BLDCYN}\h ${TXTBLK}${BAKBLU}${TXTRST}${BAKBLU}\${fill}${BLDBLU}\$newPWD ${TXTRST}\n${TXTRST}"
  76. PS2="${BLDBLK}\$? ${TXTRST}"
  77. PS3="${BLDBLK}\$? ${TXTRST}"
  78. PS4="${BLDBLK}\$? ${TXTRST}"