profile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Begin /etc/profile
  2. # Written for Beyond Linux From Scratch
  3. # by James Robertson <jameswrobertson@earthlink.net>
  4. # modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
  5. # System wide environment variables and startup programs.
  6. # System wide aliases and functions should go in /etc/bashrc. Personal
  7. # environment variables and startup programs should go into
  8. # ~/.bashrc.
  9. # Functions to help us manage paths. Second argument is the name of the
  10. # path variable to be modified (default: PATH)
  11. pathremove () {
  12. local IFS=':'
  13. local NEWPATH
  14. local DIR
  15. local PATHVARIABLE=${2:-PATH}
  16. for DIR in ${!PATHVARIABLE} ; do
  17. if [ "$DIR" != "$1" ] ; then
  18. NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
  19. fi
  20. done
  21. export $PATHVARIABLE="$NEWPATH"
  22. }
  23. pathprepend () {
  24. pathremove $1 $2
  25. local PATHVARIABLE=${2:-PATH}
  26. export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
  27. }
  28. pathappend () {
  29. pathremove $1 $2
  30. local PATHVARIABLE=${2:-PATH}
  31. export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
  32. }
  33. export -f pathremove pathprepend pathappend
  34. # Set the initial path
  35. export PATH=/usr/bin:/bin:/usr/sbin:/sbin
  36. if [ $EUID -eq 0 ] ; then
  37. unset HISTFILE
  38. fi
  39. # Setup some environment variables.
  40. export HISTSIZE=1000
  41. export HISTIGNORE="&:[bf]g:exit"
  42. # Set some defaults for graphical systems
  43. export XDG_DATA_DIRS=/usr/share/
  44. export XDG_CONFIG_DIRS=/etc/xdg/
  45. # Setup a red prompt for root and a green one for users.
  46. NORMAL="\[\e[0m\]"
  47. RED="\[\e[1;31m\]"
  48. GREEN="\[\e[1;32m\]"
  49. if [[ $EUID == 0 ]] ; then
  50. PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
  51. else
  52. PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
  53. fi
  54. for script in /etc/profile.d/*.sh ; do
  55. if [ -r $script ] ; then
  56. . $script
  57. fi
  58. done
  59. unset script RED GREEN NORMAL
  60. # End /etc/profile