My dotfiles. Period.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. ######################################################
  3. ### things to do AFTER host/user-specific settings ###
  4. ######################################################
  5. ### .... ###
  6. ### BASH ###
  7. ### '''' ###
  8. __make_ps1d() {
  9. lastrv=$(cat /var/tmp/bash-rv/$$.lastrv)
  10. if [ $lastrv -gt 126 ];
  11. then
  12. echo " \$"
  13. elif [ $lastrv -gt 0 ];
  14. then
  15. echo " \$"
  16. else
  17. echo " \$"
  18. fi
  19. }
  20. __save_rv() {
  21. echo $1 > /var/tmp/bash-rv/$$.lastrv
  22. }
  23. make_ps1() {
  24. # these functions must be already defined by ~/.bash/user/*.bashrc
  25. # and ~/.bash/host/*.bashrc
  26. svrc='$(__save_rv $?)'
  27. ps1u=$(make_ps1u)
  28. ps1h=$(make_ps1h)
  29. ps1w="$lblue\w$normal";
  30. ps1G='$(__git_ps1 "(%s)")';
  31. ps1g="$green$ps1G$normal";
  32. ps1D='$(__make_ps1d $?)';
  33. ps1d="$ps1D";
  34. echo "$svrc$ps1u@$ps1h:$ps1w$ps1g$ps1d$normal ";
  35. }
  36. make_ps2() {
  37. echo "$white>$yellow>$lyellow>$normal ";
  38. }
  39. # and use to assemble own PS1
  40. export PS1=$(make_ps1)
  41. export PS2=$(make_ps2)
  42. ### ...... ###
  43. ### OTHERS ###
  44. ### '''''' ###