dot_bashrc 628 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # non interactive? exit!
  3. [[ $- != *i* ]] && return
  4. scriptname=$(basename ${BASH_SOURCE[0]})
  5. scriptdirname=$(dirname ${BASH_SOURCE[0]})
  6. function debug () {
  7. if [ -n "$DEBUG" ]; then
  8. echo -e "[${scriptname}]: $*" >&2
  9. fi
  10. }
  11. bashrc_debug="$HOME/.BASHRC_DEBUG"
  12. if [ -f "$bashrc_debug" ]; then
  13. DEBUG="$(cat $bashrc_debug)"
  14. debug "Debug enabled."
  15. fi
  16. BASHRC_DIR="$HOME/.bashrc.d"
  17. debug "BASHRC_DIR: '$BASHRC_DIR'"
  18. if [ -d "$BASHRC_DIR" ]; then
  19. for ext in $BASHRC_DIR/*sh; do
  20. if [ -f "$ext" ]; then
  21. debug "include '$ext'"
  22. . $ext
  23. fi
  24. done
  25. else
  26. debug"BASHRC_DIR: '$BASHRC_DIR' NOT FOUND!"
  27. fi