bashrc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # /etc/bash/bashrc
  2. #
  3. # This file is sourced by all *interactive* bash shells on startup,
  4. # including some apparently interactive shells such as scp and rcp
  5. # that can't tolerate any output. So make sure this doesn't display
  6. # anything or bad things will happen !
  7. # Test for an interactive shell. There is no need to set anything
  8. # past this point for scp and rcp, and it's important to refrain from
  9. # outputting anything in those cases.
  10. if [[ $- != *i* ]] ; then
  11. # Shell is non-interactive. Be done now!
  12. return
  13. fi
  14. # Bash won't get SIGWINCH if another process is in the foreground.
  15. # Enable checkwinsize so that bash will check the terminal size when
  16. # it regains control. #65623
  17. # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
  18. shopt -s checkwinsize
  19. # Minor errors in the spelling of a directory component in a cd command
  20. # will be corrected.
  21. shopt -s cdspell
  22. # Set colorful PS1 only on colorful terminals.
  23. # dircolors --print-database uses its own built-in database
  24. # instead of using /etc/DIR_COLORS. Try to use the external file
  25. # first to take advantage of user additions.
  26. use_color=false
  27. safe_term=${TERM//[^[:alnum:]]/.} # sanitize TERM
  28. if [[ -f /etc/DIR_COLORS ]] ; then
  29. grep -q "^TERM ${safe_term}" /etc/DIR_COLORS && use_color=true
  30. elif type -p dircolors >/dev/null ; then
  31. if dircolors --print-database | grep -q "^TERM ${safe_term}" ; then
  32. use_color=true
  33. fi
  34. fi
  35. if ${use_color} ; then
  36. if [ "$EUID" = 0 ] || [ "`whoami`" == 'root' ]; then
  37. export PS1='\[\033[1;31m\]\h \[\033[1;34m\]\W \$ \[\033[00m\]'
  38. else
  39. export PS1='\[\033[1m\]\u@\h \[\033[0;31m\]\W \$ \[\033[00m\]'
  40. fi
  41. else
  42. PS1='\u@\h: \W \$ '
  43. fi
  44. # Try to keep environment pollution down, EPA loves us.
  45. unset use_color safe_term